PHP uses mkdir to create a multilevel directory method,
This example describes how PHP uses mkdir to create a multilevel directory. Share to everyone for your reference, as follows:
PHP uses mkdir () to create multi-level catalogs that are very useful when compared to a previous level of creation.
The following is a description of the functions in the PHP manual:
Copy the Code code as follows: BOOL MkDir (string $pathname [, int $mode = 0777 [, bool $recursive = False [, resource $context]])
The return value is type bool.
First parameter: must, represents the path of the multilevel directory to be created;
The second parameter: Set the permissions of the directory, the default is 0777, which means the maximum possible access rights;
The third parameter: True indicates that a multilevel directory is allowed to be created.
Note: You can create a copy of the Chinese catalog code as follows: mkdir (Iconv ("Utf-8", "GBK", $path), 0777,true); Iconv transcoding required
The complete sample code is as follows:
<?php Header ("Content-type:text/html;charset=utf-8"); The multilevel directory to be created $path = "dai/php/php learning"; Determine if the directory exists no, there is a hint, does not exist then create directory if (Is_dir ($path)) { echo "Sorry! Directory ". $path. "Already exists! "; } else{ ///The third parameter is "true" means can create multilevel directory, iconv prevent Chinese directory garbled $res =mkdir (iconv ("UTF-8", "GBK", $path), 0777,true); if ($res) { echo "directory $path created successfully"; } else{ echo "Directory $path creation failed"; } ? >
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- PHP using mkdir to create a multilevel directory Getting Started example
- An example analysis of mkdir function usage in PHP
- PHP mkdir () function Create folder more secure permission setting method
- PHP mkdir () No Write permission problem solving method
- Introduction to the use of unlink (), mkdir (), rmdir () and other methods in PHP
- PHP mkdir () Definition and usage
http://www.bkjia.com/PHPjc/1084566.html www.bkjia.com true http://www.bkjia.com/PHPjc/1084566.html techarticle PHP uses mkdir to create a multi-level directory approach, this example describes how PHP uses mkdir to create a multilevel directory. Share to everyone for your reference, as follows: PHP using mkdir () can ...