Nathan Rixham schreef:
Stut wrote:
On 11 Sep 2008, at 13:12, Ben Stones wrote:
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:
<?php
$dir=opendir(__DIR__);
while($files=readdir($dir)) {
echo $files;
}
?>
But I get a few errors:
*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!
__DIR__ is not a valid constant (yet, I think it may be planned for
5.3/6). You should be developing with notices on - this would have
told you __DIR__ is wrong.
Use dirname(__FILE__) to get what you're after.
-Stut
maybe this is into coding standards and ethics.. but this may be
acceptable:
if( !defined('__DIR__') ) {
define('__DIR__' , dirname(__FILE__));
}
however realistically you'd have to do this in every file and nto just
in one include
which would give an error on second and subsequent define()s
, as it changes on a per directory basis; hence why it'd
/need/ to be a *magic* constant I guess :)
talked myself in and out of that one; but yet still worth a post i fear!
lol
nath
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php