Getting started example of using mkdir to create a multi-level directory in PHP_PHP tutorial

WBOY
Release: 2016-07-13 10:30:02
Original
765 people have browsed it

First introduce the mkdir() function:

mkdir($path,0777,true);

The first parameter: required, represents the path of the multi-level directory to be created;
The second parameter: sets the permissions of the directory, the default is 0777, which means the maximum possible access rights;
No. Three parameters: true means allowing the creation of multi-level directories.

Example code (supports creation of Chinese directories):

header("Content-type:text/html;charset=utf-8");
//Multi-level directory to be created
$path="dai/php/php learning";
//Determine whether the directory exists. If it does, a prompt will be given. If it does not exist, create the directory
if (is_dir($path)){
echo "Sorry! Directory" . $path . "Already exists!";
}else{
//The third parameter is "true", which means that multi-level directories can be created. iconv prevents Chinese directories from being garbled
$res=mkdir(iconv("UTF-8", "GBK", $path),0777,true);
if ($res){
echo "Directory $path was created successfully";
}else{
echo "Directory $path was created failed";
}
}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/768132.htmlTechArticleFirst introduce the mkdir() function: mkdir($path,0777,true); The first parameter: Required, represents the path of the multi-level directory to be created; The second parameter: Sets the permissions of the directory, default...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template