PHP递归对文件夹递归执行chmod命令
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-07-25 08:45:05
asal
996 orang telah melayarinya
-
-
- 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, chmod
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel terbaru oleh pengarang
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
Topik-topik yang berkaitan
Lagi>