php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7185 $count++ bug (does not increase value in some cases)
Submitted: 2000-10-13 11:03 UTC Modified: 2000-10-13 12:25 UTC
From: madey at OpenBSD dot pl Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3 OS: OpenBSD 2.7 (i386)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
28 - 15 = ?
Subscribe to this entry?

 
 [2000-10-13 11:03 UTC] madey at OpenBSD dot pl
<html>
<body>
PHP 4.x : When I set $count to "", $count++ doesn't work properly.<br>
PHP 3.x : script works OK.<br>
<br>
Don't tell me that's OK ;) ... I'm perl programmer and I have some habits...<br>
<br>
Simple example of $count++ bug.<br>
(it should print 7 lines in PHP 3.x, but in PHP 4.x it loops :( )<br>
<br>
<?php

$row_count =  "7";
$count =  "";

$line =  "0";

while ($count < $row_count)
{

  print  "Line " . $line++ .  ", count : " . $count++ .  "<br>\n";

}

?>
</body>
</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-13 12:25 UTC] andi@php.net
Personally I wouldn't rely on the increment of "" being "1". I would set $count to "0" (or even better to 0).
But as it worked this way in PHP 3 and I don't see a reason not to support it I have commited a fix to the CVS tree.
Please grab it if you know how to use CVS (make sure you update the Zend CVS) and let us know if there are still problems
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 11:01:31 2024 UTC