Posted by Noodle on 01/11/07 22:01
roby wrote:
> Hello everyone, I'm a beginner in PHP and I want to ask about
> directory. How to check correctly if the directory already exist in the
> webroot? I've tried with this syntax:
> ...
> bool $state = mkdir( "test" );
> if ( $state == false ) chdir( "test" );
> ...
> but on the page there is a warning. How to solve this problem? Thanks
> in advance.
Try using the function is_dir() to test if a dir exists and is of type
directory.
http://www.php.net/manual/en/function.is-dir.php
<?php
mkdir("test");
if(is_dir("test")){
chdir("test");
}
?>
Navigation:
[Reply to this message]
|