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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alberto dot camata at telecomitalia dot it
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 07:01:28 2025 UTC