This article is mainly introduced in the PHP directory operation function Is_dir,rd_dir,mkdir and other commonly used directory operation function examples.
This article is mainly introduced in the PHP Tutorial directory operation function Is_dir,rd_dir,mkdir and other commonly used directory operation function examples.
*/
function dir_writeable ($dir)//Custom functions extension function, create writable directory
{
if (!is_dir ($dir))//If the given parameter is not a directory
{
@mkdir ($dir, 0777); Create a Directory
echo "Catalog". $dir. " Build Success! ";
}
}
Dir_writeable ("test"); Call a custom function to build the test directory
/*
Executing this code will create a directory named: Test in the current directory, and will output:
Catalog Test established successfully
*/
$dir = "Test"; Define Directory
if (RmDir ($dir))//If the directory is deleted successfully
{
echo "Catalog". $dir. " was successfully deleted! "; Output content
}
Else
{
echo "Delete directory". $dir. " , there is an error! ";
}
//
$path = "Test.txt"; Define Path
echo $path; Before the output is processed
$realpath =realpath ($path); Normalize the output with the specified absolute path
echo "
";
echo $realpath//Results after output processing
Take a look at the finishing example
function dir_writeable ($dir)//Build custom Function Extension function
{
if (!is_dir ($dir))//If the given parameter is not a directory
{
@mkdir ($dir, 0777); Create a Directory
}
if (Is_dir ($dir))
{
if ($fp = @fopen ("$dir/test.txt", ' W ')//write to open the file under the specified path, if it does not exist, create
{
@fclose ($FP); Close file handle
@unlink ("$dir/test.txt"); deleting files
$writeable = 1; Defines the return value as True
}
Else
{
$writeable = 0; Defines the return value as False
}
}
return $writeable; return value
}//Custom Function end
http://www.bkjia.com/PHPjc/631715.html www.bkjia.com true http://www.bkjia.com/PHPjc/631715.html techarticle This article is mainly introduced in the PHP directory operation function Is_dir,rd_dir,mkdir and other commonly used directory operation function examples. This article is mainly introduced in PHP Tutorial directory operation function Is_dir,rd_di ...