Home >Backend Development >PHP Tutorial > php 改变文件目录上文件的后缀名

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 13:02:20899browse

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);
    }
}
?

?

?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn