php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11114 fopen or fclose sum 2 to $var into file
Submitted: 2001-05-25 11:15 UTC Modified: 2001-06-03 03:46 UTC
From: alberto dot camata at telecomitalia dot it Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.4pl1 OS: WINNT 4.0 & Apache
Private report: No CVE-ID: None
 [2001-05-25 11:15 UTC] alberto dot camata at telecomitalia dot it
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);
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-03 03:46 UTC] sniper@php.net
Works for me just fine.
Update to PHP 4.0.5.

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 09:01:27 2024 UTC