Jump to content

Converting fread() to int


brenhein

Recommended Posts

Hello.

 

I need help adding a text file content by one and then saving.

 

My current code is

								$myFile = "serving";
$fh = fopen($myFile, 'w+') or die("can't open file");
$conv = fread($fh, 4);
$stringData = $conv++;
fwrite($fh, $stringData);
fclose($fh);

 

I was told this would work, but of course, it doesn't.  It always returns 1.

 

I also tried casting it as an int by using

$stringData = (int) $conv++;

Link to comment
https://forums.phpfreaks.com/topic/223773-converting-fread-to-int/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.