PHP對文件夾遞歸執(zhí)行chmod命令的方法
更新時間:2015年06月19日 16:42:10 作者:不吃皮蛋
這篇文章主要介紹了PHP對文件夾遞歸執(zhí)行chmod命令的方法,可實現遞歸執(zhí)行chmod命令改變文件夾執(zhí)行權限的功能,需要的朋友可以參考下
本文實例講述了PHP對文件夾遞歸執(zhí)行chmod命令的方法。分享給大家供大家參考。具體分析如下:
這里對文件夾和文件遞歸執(zhí)行chmod命令來改變執(zhí)行權限
<?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使用escapeshellarg時中文被過濾的解決方法
這篇文章主要介紹了php使用escapeshellarg時中文被過濾的解決方法,測試后發(fā)現問題的原因是shell和apache php-cgi的運行環(huán)境不同引起的,需要的朋友可以參考下2016-07-07PHP常用工具函數小結【移除XSS攻擊、UTF8與GBK編碼轉換等】
這篇文章主要介紹了PHP常用工具函數,結合實例形式總結分析了php移除XSS攻擊、以及php操作UTF8與GBK編碼轉換等相關操作自定義函數實現方法,需要的朋友可以參考下2019-04-04phpadmin如何導入導出大數據文件及php.ini參數修改
新版本的phpadmin導入限定是8M,老版本的可能2M;如果遇到幾十兆的該怎么辦呢?接下來本文將介紹詳細的修改方法,感興趣的你可不要錯過了哈,或許本文提供的知識點對你有所幫助2013-02-02