zyk198500 发表于 2017-4-12 09:00:16

php 改变文件目录下文件的后缀名

changeTypeName("E:/bak/video/code/views", "html", "phtml");
//改变文件目录下文件的后缀名
function changeTypeName($path, $oldTypaName, $newTypeName)
{
$path = "glob://$path/*";
$files = new DirectoryIterator($path);
foreach ($files as $file) {
$fileRealPath = $file->getRealPath(); //文件绝对路径
$compressCssFileRealPath = str_replace(".$oldTypaName", ".$newTypeName", $fileRealPath);
rename($fileRealPath, $compressCssFileRealPath);
}
}
 
页: [1]
查看完整版本: php 改变文件目录下文件的后缀名