Through the code, summarize the PHP file functions
Current Directoryecho getcwd (). "\ n"; chdir (' hhh ');//Current Directoryecho GETCWD (). "\ n";
D:\xampp\htdocs\my\function
D:\xampp\htdocs\my\function\hhh
$dir = ' D:\xampp\htdocs\my\function ';//Open a known directory, read directory into variable and then Closeif (Is_dir ($dir ) { if ($dh = Opendir ($dir)) { $ds = array (); while ($directory = Readdir ($DH)) { $ds [] = $directory; } Rewinddir ($DH); while ($directory = Readdir ($DH)) { $ds [] = $directory; } Closedir ($DH); }} Print_r ($DS);
Array ([0] = =. [1] = =. [2] = = file.php [3] = HHH [4] = =. [5] = =. [6] = file.php [7] = HHH)
$dir = ' D:\xampp\htdocs\my\function '; Showfiles3 ($dir); function Showfiles1 ($dir) {if (Is_dir ($dir)) {echo]
"; $DH = Opendir ($dir); while ($file = Readdir ($DH)) {if (Is_dir ($dir. Directory_separator. $file) {if ($file! = '. ' && $file! = ') {echo "
- "; echo "|"-$file; Showfiles1 ($dir. Directory_separator. $file); echo "
"; }} else{echo "
- "; echo "--". $file; echo "
"; }} closedir ($DH); echo "
"; }}function Showfiles2 ($dir) {echo]
"; $arr = Scandir ($dir); foreach ($arr as $file) {if (Is_dir ($dir. Directory_separator. $file) {if ($file! = '. ' && $file! = ') {echo "
- "; echo "|"-$file; Showfiles2 ($dir. Directory_separator. $file); echo "
"; }} else{echo "
- "; echo "--". $file; echo "
"; }} echo "
";} function Showfiles3 ($dir) {foreach (Glob ($dir. Directory_separator. ' * ') as $f) {echo is_dir ($f)? Showfiles3 ($f): "$f
"; }}
$dir = ' D:\xampp\htdocs\my\function '; $d = Scandir ($dir, 1);p Rint_r ($d);
Array ([0] = HHH [1] = file.php [2] = =. [3] = =. )
The retrieval function of the directory Glob ()//Retrieves all "*.txt" files in the current directory $files = Glob ("*.txt");//retrieves all subdirectories with "T" in the current directory $files = Glob ("t*", Glob_onlydir); /Retrieve all PHP files starting with "D,t or P" in the current directory $files = Glob ("{d,t,p}*.php", glob_brace);
A little bit of a question:. File and. Detailed analysis of the file