Re: Readdir() question

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

 



Ben Stones schreef:
Hi,

I'm going to make a small browser based file system for ease of small
updates that I make frequently on my Website. First of all I want to loop
all the files on the same directory and to tell PHP read the same directory,
I think I'd need to use the magic constant I think its called, __DIR__ such
as:

__DIR__ does not exist unless your using php5.3 ... and your not.

your still not bothering to develop with error_reporting set to 'full'
namely E_ALL | E_STRICT, probably it's set to E_ALL ^ E_NOTICE ... no idea what
I'm talking about?

read this: http://php.net/error_reporting


<?php
$dir=opendir(__DIR__);
while($files=readdir($dir)) {
    echo $files;
}
?>

But I get a few errors:

code you write should check for errors, namely checking to see whether opendir()
failed or not, if it did fail output don't try to loop through the files using readdir(),
output an error message or something instead.


*Warning*: opendir(__DIR__) [function.opendir]: failed to open dir: No error
in *C:\wamp\www\Project1\index.php* on line *2*

*Warning*: readdir(): supplied argument is not a valid Directory resource in
*C:\wamp\www\Project1\index.php* on line *3

*Any help in the right direction will be appreciated!

Cheers.



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