Today bored practice a bit of PHP traversal file directory program, wrote the following two programs, but the quality is not very good, Pat ~ ~ ~
1. Clear the PHP cache file
<?phpfunction Read_dir ($dir, $file) {$a =strpos ($file, ". php"), if ($a >0) {unlink ($dir. $file); echo "Delete $dir $ File <br> "; return true;} if (Strpos ($file, ".") = = = 0 | | Strpos ($file, ".")! = = False) return True;if (Strpos ($file, ".") = = = False | | Strpos ($dir, "/") = = = False) {$dir = $dir. $file. "/"; if (!is_dir ($dir)) return false; $dh = Opendir ($dir); while (($file = Readdir ($DH) = = False) {Read_dir ($dir, $file); Recursive call}}}function clear_caches () {$dir = "./temp/"; The PHP cache file directory to be purged if (!is_dir ($dir)) Die ("It was not a dir"), $dh = Opendir ($dir), while (($file = Readdir ($DH))!=false) {//var_ Dump ($file); Read_dir ($dir, $file);}}? >