Re: PHP 4.0 Bug #5455 Updated: readdir() still doesn't work
| From: | Rasmus Lerdorf | Date: | Fri, 14 Jul 2000 12:50:51 +0000 |
| Subject: | Re: PHP 4.0 Bug #5455 Updated: readdir() still doesn't work | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-24523@lists.php.net to get a copy of this message | ||
I am unable to reproduce this.
See: http://www.php.net/~rasmus/test/readdir.php
Run it as many times as you want. It never fails.
The code is at: http://www.php.net/~rasmus/test/readdir.phps
This is using 4.0.2-dev from a couple of days ago.
-Rasmus
On 15 Jul 2000, Bug Database wrote:
> ID: 5455
> User Update by: johan@ekenberg.se
> Status: Feedback
> Bug Type: Misbehaving function
> Description: readdir() still doesn't work
>
> 1. The while loop is only evaluated once, despite the fact that there are more directory
> entries to list. I earlier wrote that the while-loop exits at the first evaluation of the
> if-statement, but that is not true. The execution continues after the if-statement until the end of
> the while loop, there it exits. If the if-statement is removed or commented out, the while loop will
> continue looping until all entries in the directory are listed. With the if-statement left in place
> it's exactly like putting "break;" as the last line of the while loop - it never
> evaluates more than once. I guess that something in the if-statement makes readdir($dir) evaluate to
> false the next time.
>
> $dir = opendir(".");
> while ($file = readdir($dir)) {
> print "<br>$file";
> if ($file == "foo") {
> // anything or nothing here, doesn't matter
> }
> // Code placed here will also be evaluated,
> // but as long as the if-statement above is not
> // removed, the while loop will exit after
> // completing once - like putting a
> // break;
> // as the last line of the while loop.
> }
>
> I earlier submitted an URL with a working example which I believe displays the issue rather
> clearly: http://www.ekenberg.se/readdir/index.php
>
> 2. "gdb -X httpd" doesn't report anything unusual - httpd happily keeps on
> executing, there are no errors and it doesn't exit. zend_bailout() is never called.
>
>
> Full Bug description available at: http://bugs.php.net/?id=5455
>
>
>