//判断目录不存在则创建目录
if (!is_dir($path)){
//第三个参数是“true”表示能创建多级目录,iconv防止中文目录乱码
mkdir(iconv("UTF-8", "GBK", $path), 0777, true);
}
if (!file_exists($filePath))
{
$content = file_get_contents($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . '/index.php?r=home/lost-retrieved/index&language=' . $language);
$handle = fopen ($filePath, "w");//打开文件指针,创建文件
if (!is_writable ($filePath)){
die ("文件:".$filePath."不可写,请检查其属性后重试!");
}
if (!fwrite ($handle, $content)){
die ("生成文件".$filePath."失败!");
}
fclose ($handle); //关闭指针
}
php根据链接生成静态页
转载请注明出处:猿客栈 » php根据链接生成静态页