PHP file traversal small example

WBOY
Release: 2016-07-25 09:11:51
Original
811 people have browsed it

PHP file traversal small example

Full code:

  1. $dir = "D:workspace";
  2. function list_file($dir = '.'){
  3. $list = scandir($dir);
  4. echo '
      ';
    1. foreach($list as $file){
    2. $target = "$dir/$file";
    3. if ( is_dir($target) && $file != '.' && $file != '..' ) {
    4. echo "
    5. $file
    6. ";
    7. list_file($target);
    8. } else if ( $file != '.' && $file != '..'){
    9. echo "
    10. $file
    11. ";
    12. }
    13. }
    14. echo '
    ';
  5. }
  6. list_file($dir);
Copy code


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!