PHP 4.0 Bug #10026 Updated: For loop always execute
| From: | sniper@php.net | Date: | Sun, 01 Apr 2001 17:34:29 +0000 |
| Subject: | PHP 4.0 Bug #10026 Updated: For loop always execute | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-50490@lists.php.net to get a copy of this message | ||
ID: 10026
Updated by: sniper
Reported By: svein@edbc.no
Old-Status: Open
Status: Feedback
Bug Type: *General Issues
Assigned To:
Comments:
As I can not reproduce this with latest CVS please try
the latest snapshot from http://snaps.php.net/
And if happens with it too, create one
short but self-containing script which can be used
to reproduce this anywhere without modifications
and add it into this bug report.
--Jani
Previous Comments:
---------------------------------------------------------------------------
[2001-03-29 12:57:01] svein@edbc.no
When i said ONCE - i didnt mean ONCE :)
It ALWAYS happen in the code referred...
---------------------------------------------------------------------------
[2001-03-29 12:55:32] svein@edbc.no
Its not easy reproduceable - i have only seen this happens ONCE - in the specified function. Its NOT
a simple for-loop - the for-loop executes INSIDE a recursively called function.
I've also tried this one :
---
$c = count($myarray);
if ($c>0) {
echo "c is greater than 0<br>";
for (...) {
...code
}
}
---
then IF c is 0 the echo statement doesnt execute BUT the for loop executes...
I cant figure out why...
If some of you want it i can mail you the file so you can see the things in perspective.
- Svein
---------------------------------------------------------------------------
[2001-03-29 11:55:23] sniper@php.net
I can't reproduce this (using code below):
<?php
$c=0;
for($i=0; $i<$c; $i++) {
echo "yesn";
}
?>
Could you try this one?
And note: If the variable passed to count() is not an array,
it will return 1.
--Jani
---------------------------------------------------------------------------
[2001-03-27 11:09:08] svein@edbc.no
The code submitted is inside a function that is called recursively and its not exact copy of the
code.
I've also tried to change the for loop to a while loop with the same result.
---------------------------------------------------------------------------
[2001-03-27 11:07:07] svein@edbc.no
I have a strange situation;
I have this code :
$c = count($myarray);
echo $c . '<br>';
for ($i=0; $i<$c; $i++) {
code goes here...
}
echo often often output that $c is 0 BUT the for loop ALWAYS execute...
I also have tried to sorrund the for loop with this :
if ($c>0) {
for(...)
}
and it STILL execute if $c==0
---------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view the rest of the comments,
please view the bug report online.
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=10026&edit=2