php 页面页面静态化 $fp = fopen($path, 'wb'); fwrite($fp, $html); fclose($fp)

<?php
date_default_timezone_set('PRC');
$html = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/template.tpl');
$title = '新闻';
$header = '新闻内容';
$content = '我中大奖了';
$html = preg_replace('/\{\$title\}/', $title, $html);
$html = preg_replace('/\{\$header\}/', $header, $html);
$html = preg_replace('/\{\$content\}/', $content, $html);
//print $html;

//静态化页面
$path = $_SERVER['DOCUMENT_ROOT'].'/static/'.date('YmdHis').'.html';
$fp = fopen($path, 'wb');
fwrite($fp, $html);
fclose($fp);
浏览器会这么报错

帮忙看看哪里不对?

你看看这个文件的目录存在不存在,不存在的话先创建目录
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网