php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19761 Big numbers add problem
Submitted: 2002-10-04 16:03 UTC Modified: 2002-10-04 19:48 UTC
From: vinicius at teracom dot com dot br Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4CVS-2002-10-04 OS: Linux Redhat 7.3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vinicius at teracom dot com dot br
New email:
PHP Version: OS:

 

 [2002-10-04 16:03 UTC] vinicius at teracom dot com dot br
Problem find by paulo@teracom.com.br 
When run this script everything goes fine until we reach number 2147483647. In php 4.0.4, it turns the number negative. In latest CVS, it stop add value to the number.

There is the script! To recriate the problem, put the 2147483640 value in stats.txt and refresh the page many times. The number do not pass 2147483648.

Here's the script.

<?
$counter_file = "stats.txt";
$fp = fopen($counter_file, "r");
$counter = (int)fread($fp, 24);
$close = fclose($fp);

if (!isset($hits)) {
   $counter++;
   setcookie("hits","1");
} else {
   $counter++;
   setcookie("hits","$counter");
}
 
$fp = fopen($counter_file , "w");
fwrite($fp, $counter);
fclose($fp);

print "Number: $counter";           
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-04 19:48 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 10:01:38 2025 UTC