国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP對文件夾遞歸執行chmod命令的方法

2024-05-04 23:36:39
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了PHP對文件夾遞歸執行chmod命令的方法,可實現遞歸執行chmod命令改變文件夾執行權限的功能,需要的朋友可以參考下

本文實例講述了PHP對文件夾遞歸執行chmod命令的方法。分享給大家供大家參考。具體分析如下:

這里對文件夾和文件遞歸執行chmod命令來改變執行權限

 

 
  1. <?php 
  2. function recursiveChmod($path$filePerm=0644, $dirPerm=0755) 
  3. // Check if the path exists 
  4. if(!file_exists($path)) 
  5. return(FALSE); 
  6. // See whether this is a file 
  7. if(is_file($path)) 
  8. // Chmod the file with our given filepermissions 
  9. chmod($path$filePerm); 
  10. // If this is a directory... 
  11. elseif(is_dir($path)) { 
  12. // Then get an array of the contents 
  13. $foldersAndFiles = scandir($path); 
  14. // Remove "." and ".." from the list 
  15. $entries = array_slice($foldersAndFiles, 2); 
  16. // Parse every result... 
  17. foreach($entries as $entry
  18. // And call this function again recursively, with the same permissions 
  19. recursiveChmod($path."/".$entry$filePerm$dirPerm); 
  20. // When we are done with the contents of the directory, we chmod the directory itself 
  21. chmod($path$dirPerm); 
  22. // Everything seemed to work out well, return TRUE 
  23. return(TRUE); 
  24. ?> 

希望本文所述對大家的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兰溪市| 荔浦县| 田林县| 讷河市| 黔西县| 罗源县| 邵阳市| 万全县| 名山县| 志丹县| 八宿县| 北碚区| 张家界市| 阳西县| 福清市| 中超| 天峨县| 东乌珠穆沁旗| 宿州市| 扬中市| 大港区| 拉孜县| 乐安县| 乌什县| 清丰县| 涪陵区| 潼南县| 新密市| 汝阳县| 承德县| 砚山县| 惠州市| 汤阴县| 松原市| 金门县| 元朗区| 柘城县| 铁岭市| 宁乡县| 高青县| 安吉县|