| Bug #7185 | $count++ bug (does not increase value in some cases) | ||||
|---|---|---|---|---|---|
| Submitted: | 13 Oct 2000 11:03am UTC | Modified: | 13 Oct 2000 12:25pm UTC | ||
| From: | madey at OpenBSD dot pl | Assigned to: | |||
| Status: | Closed | Category: | Scripting Engine problem | ||
| Version: | 4.0.3 | OS: | OpenBSD 2.7 (i386) | ||
[13 Oct 2000 12:25pm 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

<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>