User Contributed Notes: is_dir
php@wastelan.com
11-Jun-1999 12:55
it appears like is_dir and is_file don't work
like you would expect.
is_dir("..") returns true
and yet is_dir("x") where x is a dir does not
me@seanbright.com
17-Jul-1999 07:03
Inconsistancy between is_dir and is_readable. is_readable does not
work on directories unless they are followed by a '/'. is_dir however
works even if there is no trailing slash. I am not sure if this is a UNIX
based issue or not, but remember to add that trailing slash. Hopefully
this will save someone else the time that I wasted ;)
php3-user@mindcontrol.org.NoSpam
16-Aug-1999 10:57
I think the first user's comments are based on being confused about the working directory for PHP3 scripts. The cwd is NOT necessarily the same as the location of the script. Use chdir() to set the CWD if you don't pass a full path to this functions (and others taking file names).
whit@asan.com
24-Aug-1999 12:48
Somewhere between 3.0.5 and 3.0.12 there was apparently a change in this function. 3.0.5 worked fine with "if (!is_dir($file))" constructions, where this followed an opendir(whatever) and $file=readdir() - without any further attention to path (must have been maintaining path info internally?). 3.0.12 apparently fails even with specifying the full path. This is on two Solaris systems, otherwise identical. is_file appears similarly dysfunctional.
whit@asan.com
24-Aug-1999 12:54
Correction, it does work now if you fully specify the path - but it used to not require it. So the documentation should note that a previous convenient functionality has been broken, and older scripts may need adjustment.
fnemec@sti.com.br
18-Feb-2000 03:02
I get a problem using is_dir() function.
If I do is_dir( "home/httpd/html/anydir" ) where anydir is a valid dir, sometimes I get a false result! If anyone knows what happens, please, help me! :)
duden@earthling.net
22-Feb-2000 06:41
I had problems with is_dir too.
They were like
is_dir("mydir/subdir") returns false
here my workaround:
chdir("mydir");
is_dir("subdir") works and returns true
hope it helps
lucian@hitel.net
15-Mar-2000 12:19
seems like is_dir, is_file and is_link work correctly _only_ for filenames that have absolute path. while
<pre>
is_dir("index.html");
</pre>
produces false result,
<pre>
is_dir("$document_root/index.html");
</pre>
produces correct result.
richards@herald.net
12-May-2000 12:22
fnemec: Your example seems to be missing an initial / . If that was cut-and-pasted from your code, that's probably your problem.
In all cases, you're probably better off passing fully pathed directories, though.
yorx@enter.vg
12-Jul-2000 05:26
It appears that is_dir does not work properly on win32, and returns false if the directory name has a trailing \. ex: is_dir('c:\\php') returns true while is_dir('c:\\php\\') returns false.