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