php文件与目录结构_PHP文件与目录操作示例解析

时间:2020-12-18  来源:php函数  阅读:

本文实例讲述了PHP文件与目录操作。分享给大家供大家参考,具体如下:

文件目录相关函数

";      }     }    }   }  } }else{  echo"对不起,这个目录不存在."; } } $allowedtypes=array("txt","html"); outputcurfiles ($allowedtypes,"testfolder"); /////////////////////////////////////////////////// functionrecurdir ($thedir) {   //First attempt to open the directory.   try{     if($adir= opendir ($thedir)){       //扫描目录。       while(false !== ($anitem= readdir ($adir))){         //不统计目录中包含“.”或“..”的情况         if($anitem!="."&&$anitem!=".."){           //此时如果是一个目录,则缩进一点           //再去递归           if(is_dir($thedir."/".$anitem)){             ?>";           }         }       }     }else{       thrownewexception ("Sorry, directory could not be openend.");     }   }catch(exception$e) {     echo$e->getmessage();   } } echo"
/////////////////////////////////////

"; recurdir("testfolder"); ////////////////////////////////////////////////////////////////// echo"
/////////////////////////////////////

"; functionsortfilesbydate ($thedir){   //首先,需要确保目录存在。   if(is_dir($thedir)){     //接着,我们使用scandir扫描此目录中的文件.     $scanarray= scandir ($thedir);     $finalarray=array();     //然后开始解析数组     //scandir()用“.”和“..”统计文件导航列表     //因此作为文件,我们不应该列出他们.     for($i= 0;$i"; } ?>

php文件与目录结构_PHP文件与目录操作示例解析

http://m.bbyears.com/jiaocheng/117129.html

推荐访问:php文件怎么运行 php格式文件怎么打开 php读取文件内容
相关阅读 猜你喜欢
本类排行 本类最新