[英]How can I replace multiple PHP files in different directories with an updated PHP file using PHP
我怎样才能更换不同的目录中的多个PHP文件使用PHP例如相同的PHP文件,如何更换所有index.php
例1中的文件与index.php
例2中的文件
示例1网址值
/files/user-2/a/index.php
/files/user-12/a/index.php
/files/user-23/a/index.php
/files/user-232/a/index.php
/files/user-2232/a/index.php
示例2网址值
/files/user-2/a/index.php
/files/user-12/a/index.php
/files/user-23/a/index.php
/files/user-232/a/index.php
/files/user-2232/a/index.php
您应该使用重命名功能( http://php.net/manual/en/function.rename.php )
要使用它,首先要解析dir内容:
function renameFilesInDir($dirName) {
$dir = opendir($dirName);
while ($file = readdir($dir)) {
if (is_file($dirName.$file)) {
// Rename the File
}
}
closedir($dir);
}
祝好运 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.