Home > Article > Backend Development > PHP directory php php directory operation php mkdir multi-level directory
Directory operation
Recursively read directory contents
showDir('../../file');
functionshowDir($path,$dep=0){$pos = opendir($path);
while(false!==$file=readdir($pos)){
if($file=='.'||$file=='..') continue;
echo str_repeat(" ",$dep*4),$file.'';
if(is_dir($path.'/'.$file)){
$func = __FUNCTION__;
$func($path.'/'.$file,$dep+1);
}
}
}
The above has introduced the PHP directory, including PHP and directory content. I hope it will be helpful to friends who are interested in PHP tutorials.