1. 程式人生 > >php html 靜態化 快取

php html 靜態化 快取

<?php 
// // ob_start();
$cache_name = md5(__FILE__). '.html';
$cache_lifetime = 3600;
// echo filectime(__FILE__)."<br>";
// echo filectime($cache_name)."<br>";
// echo file_exists($cache_name)."<br>";
// echo filectime($cache_name)+$cache_lifetime."<br>";
// echo $cache_lifetime."<br>";
// echo time();
if(filectime(__FILE__) <= filectime($cache_name) && file_exists($cache_name) && filectime($cache_name) + $cache_lifetime > time()) { exit('123'); include $cache_name; exit; } ob_start(); ?> <b> 搜發 藕粉 qwe色【 皮aasd膚 dsdfg開始s sss打破12s3123</b> <?php
$content = ob_get_contents(); ob_end_flush(); $handle = fopen($cache_name, 'w'); fwrite($handle, $content); fclose($handle); ?>