《PHP編程:PHP對(duì)文件夾遞歸執(zhí)行chmod命令的方法》要點(diǎn):
本文介紹了PHP編程:PHP對(duì)文件夾遞歸執(zhí)行chmod命令的方法,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
PHP學(xué)習(xí)本文實(shí)例講述了PHP對(duì)文件夾遞歸執(zhí)行chmod命令的辦法.分享給大家供大家參考.具體分析如下:
PHP學(xué)習(xí)這里對(duì)文件夾和文件遞歸執(zhí)行chmod命令來(lái)改變執(zhí)行權(quán)限
PHP學(xué)習(xí)
<?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學(xué)習(xí)希望本文所述對(duì)大家的php程序設(shè)計(jì)有所贊助.
維易PHP培訓(xùn)學(xué)院每天發(fā)布《PHP編程:PHP對(duì)文件夾遞歸執(zhí)行chmod命令的方法》等實(shí)戰(zhàn)技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養(yǎng)人才。
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/10276.html