Re: fopen('.', 'r') succeeds !?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim Streater wrote:

> When scanning a directory I do this (leaving out error handling and recursion details):
> 
>      $start = '/path/to/here'
> 
>      $dirh = opendir ($start);
> 
>      while  (true)
>           {
> 
>           $nextfile = readdir ($dirh);
>           if  ($nextfile===false)  break;
>
> Seems to work.

A caveat: when opendir() fails (because the directory doesn't exist, for
instance), it returns false.  However, readdir(false) returns null, so
you would have an infinite loop.

-- 
Christoph M. Becker


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux