PHP对文件夹递归执行chmod命令的方法
时间:2022-01-21 03:32:35|来源:网络精心整理
这篇文章主要讲解的是PHP对文件夹递归执行chmod命令的方法,文章内容非常详细,相信一定可以解决你的问题,需要的朋友可以参考下哦
本文实例讲述了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程序设计有所帮助。
本文地址:https://www.tabangni.com/phpstudy/5540.html
查看更多与“文件夹PHPchmod”有关的文章
- 01-17PHP中基本符号及使用方法
- 01-19PHP count_chars()函数讲解
- 01-17PHP hex2bin()函数用法讲解
- 01-16PHP implode()函数用法讲解
- 01-20PHP lcfirst()函数定义与用法
- 01-20PHP join()函数用法与实例讲解
- 01-19PHP中quotemeta()函数的用法讲解
- 01-18PHP中number_format()函数的用法讲解
- 01-18PHP中str_split()函数的用法讲解
- 01-17一个正则的写法 php
- 01-16php 正则表达式学习笔记
- 01-17php下常用表单验证的正则表达式
- 01-20PHP 正则表达式分析RSS
- 01-16PHP 正则表达式验证中文的问题
- 01-18php中utf-8编码下用正则表达式如何匹配汉字
- 01-16PHP正则匹配图片并给图片加链接详解
- 01-17PHP 正则表达式的几则使用技巧
- 01-18PHP 正则表达式常用函数使用小结
- 01-18php 正则 不包含某字符串的正则表达式
- 01-18PHP 正则 email语句详解
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
推荐阅读
最近更新
- 01-21深入研究HTML5实现图片压缩上传功能
- 01-21PHP对文件夹递归执行chmod命令的方法
- 01-21HTML5响应式(自适应)网页设计的实现
- 01-21nginx配置支持php的pathinfo模式配置方法
- 01-21技术牛人说明My Desktop :) 桌面式代码
- 01-21优秀技术员讲解js保留小数点后几位的写法
- 01-21主编讲说javascript实现网页端解压并查看zip文件
- 01-21笔者解读JavaScript深度复制(deep clone)的实现方法
- 01-21资深技术员讲诉全面解析Bootstrap中Carousel轮播的使用方法
- 01-21php利用cookies实现购物车的方法