加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP编程:PHP对文件夹递归执行chmod命令的方法

发布时间:2020-12-13 02:41:29 所属栏目:PHP教程 来源:网络整理
导读:《PHP对文件夹递归执行chmod命令的方法》要点: 本文介绍了PHP对文件夹递归执行chmod命令的方法,希望对您有用。如果有疑问,可以联系我们。 PHP学习 本篇章节讲解PHP对文件夹递归执行chmod命令的办法.供大家参考研究.具体分析如下: 这里对文件夹和

《PHP对文件夹递归执行chmod命令的方法》要点:
本文介绍了PHP对文件夹递归执行chmod命令的方法,希望对您有用。如果有疑问,可以联系我们。

PHP学习本篇章节讲解PHP对文件夹递归执行chmod命令的办法.分享给大家供大家参考.具体分析如下:

这里对文件夹和文件递归执行chmod命令来改变执行权限


<?php
  function recursiveChmod($path,$filePerm=0644,$dirPerm=0755)
  {
   // Check if the path exists
   if(!file_exists($path))
   {
     return(FALSE);
   }
   // See whether this is a file
   if(is_file($path))
   {
     // Chmod the file with our given filepermissions
     chmod($path,$filePerm);
   // If this is a directory...
   } elseif(is_dir($path)) {
     // Then get an array of the contents
     $foldersAndFiles = scandir($path);
     // Remove "." and ".." from the list
     $entries = array_slice($foldersAndFiles,2);
     // Parse every result...
     foreach($entries as $entry)
     {
      // And call this function again recursively,with the same permissions
      recursiveChmod($path."/".$entry,$filePerm,$dirPerm);
     }
     // When we are done with the contents of the directory,we chmod the directory itself
     chmod($path,$dirPerm);
   }
   // Everything seemed to work out well,return TRUE
   return(TRUE);
  }
?>

希望本文所述对大家的php程序设计有所赞助.

编程之家培训学院每天发布《PHP对文件夹递归执行chmod命令的方法》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读