|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-03 03:46 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 15:00:01 2025 UTC |
This is excercise to create a counter but when i go to see the content of file i see the counter+2 ? P.s : $num2 that I read the second time it's right, I used it as a dump variable. If I remove $num++ all it's fine <?php if (!file_exists("counter.txt")) { $file=fopen("counter.txt","w"); $num="0"; } else { $file=fopen("counter.txt","r+"); $num= fgets($file,4); } print("<H1><BOLD>".$num." visite dal 22 maggio 2001</BOLD><BR><BR>"); $num=$num+1; rewind($file); print($num."<BR><BR>"); fputs($file,$num); fclose($file); $file=fopen("counter.txt","r+"); $num2= fgets($file,4); print(" NUM2 ".$num2); ?>