【发布时间】:2013-08-11 09:33:47
【问题描述】:
我想每 x 分钟缓存一次我的主页,因为它有很多请求并且内容不会经常更改,
这就是我正在尝试的:
<?php
ini_set('error_reporting', 1);
error_reporting(E_ALL);
$path = '/home/......../mypath/html/';
if(true){
$homePage = file_get_contents($path.'index.php');
file_put_contents('indexx.html', $homePage);
//echo $homePage;
}
?>
问题是它没有得到 html 结果代码,而是返回了 php 代码(我对此感到非常不满.....)
知道为什么吗?以及如何获取渲染版本?
谢谢
【问题讨论】:
-
我认为其他帖子包含您的答案:stackoverflow.com/questions/851367/…
-
将
$path更改为有效的http 资源。例如,如果您的站点位于localhost/website下,则使用http://localhost/website/。这是针对 file_get_contents 部分的,file_put_contents 应该像'/home/......../mypath/html
标签: php caching file-get-contents