[英]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.