Home > Backend Development > PHP Tutorial > Summary of PHP directory traversal methods, PHP directory traversal summary_PHP tutorial

Summary of PHP directory traversal methods, PHP directory traversal summary_PHP tutorial

WBOY
Release: 2016-07-13 10:04:18
Original
918 people have browsed it

Summary of PHP directory traversal method, PHP directory traversal summary

The example in this article summarizes the PHP directory traversal method. Share it with everyone for your reference. The details are as follows:

1. Method 1

<&#63;php
  function myscandir($pathname){
    foreach( glob($pathname) as $filename ){
      if(is_dir($filename)){
        myscandir($filename.'/*');
      }else{
        echo $filename.'<br/>';
      }
    }
  }
  myscandir('D:/wamp/www/exe1/*');
&#63;>
Copy after login

2. Method 2

<&#63;php
  function myscandir($path){
    $mydir=dir($path);
    while($file=$mydir->read()){
      $p=$path.'/'.$file;
      if(($file!=".") AND ($file!="..")){
      echo $p.'<br>';
      }
      if((is_dir($p)) AND ($file!=".") AND ($file!="..")){
        myscandir($p);
      }
    }  
  }
  myscandir(dirname(dirname(__FILE__)));
&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/965565.htmlTechArticleSummary of PHP directory traversal method, PHP directory traversal summary. This example summarizes the PHP directory traversal method. Share it with everyone for your reference. The details are as follows: 1. Method 1 php function myscandir($pa...
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