打开或存储指定目录下的文件
于 2024-04-28 发布 阅读量58
/**
* 打开目录中指定的文件
* file_get_contents 打开指定文件
* htmlspecialchars 转义
*/
header("Content-type:text/html; charset=utf-8"); //处理中文乱码
$dir1 = $dir."article/index.htm";
$content = htmlspecialchars(file_get_contents($dir1));
//echo $content;
/**
* 把内容存入指定文件中
* file_put_contents 把指定内容存入指定文件中
* htmlspecialchars_decode 反转义
*/
$dir2 = $dir."article/index1.htm";
file_put_contents($dir2,htmlspecialchars_decode($content)); 