php recursively gets the file encapsulation class sharing within the directory, can recursively subdirectory
Code as follows: code is as follows: function Readfilefromdir ($dir) { if (!is_dir ($dir)) { return False } //Open Directory $handle = Opendir ($dir); while ($file = Readdir ($handle))!== false) { //Exclude current directory and previous directory &NB Sp if ($file = = "." | | $file = = "...") { Continue } $file = $d Ir. Directory_separator. $file; //If the file is printed, otherwise recursive call if (Is_file ($file)) { &NB Sp Print $file. ' <br/> '; } elseif (Is_dir ($file)) { Readfilefromdir ($file); nbsp } } { call: code as follows: $dir = '/home/www/test '; readfilefromdir ($ DIR); Looking at the PHP manual, there is another way scandir can also be used, notThis method will be a one-time access to all the files in the single level directory, stored in the array, if the directory more than the file, will card.