Home >Backend Development >PHP Problem >How to set up php directory
How to set the directory in php: first create a PHP sample file; then create the directory through the "mkdir('test',0644)" function; and finally set the relevant permission parameters.
The operating environment of this tutorial: windows10 system, php5.6. This article is applicable to all brands of computers.
Recommended: "PHP Video Tutorial"
php setting directory:
Create and delete directories
1.mkdir(' test',0644): Create directory
bool mkdir ( string pathname [, intpathname[,intmode = 0777 [, bool recursive = false [, resourcerecursive=false[,resourcecontext ]]] )
Note: $mode is the permission. Users, groups, and other users each have permissions of r=4/w=2/x=1, such as 0644 is rw_/r__ /r__ (Knowledge of Linux permissions)
2.rmdir('test'): Delete the directory. Note that the directory must be empty
3.unlink('test.php'): Delete the file
4. Use recursion to delete non-empty directories, as follows:
**注:切记排除目录下的.和..,否则会删除整个磁盘内容,且不进回收站!** function deleteDir($dirname){ $dir=opendir($dirname); while($filename=readdir($dir)){ if($filename!=='.'&&$filename!=='..'){ $filename=$dirname.'/'.$filename; if(is_dir($filename)){ deleteDir($filename); }else{ unlink($filename); } } } closedir($dir); rmdir($dirname); } deleteDir('test');
The above is the detailed content of How to set up php directory. For more information, please follow other related articles on the PHP Chinese website!