mkdir($this->cacheDir, 0777); } $fp = fopen($this->cacheDir . '/' . $this->fileName . '.html', 'w+'); fwrite($fp, $cacheData); fclose($fp); return true; } public function cacheRemove($cacheName = '') { return is_string($cacheName) && $cacheName != '' ? unlink($this->cacheDir . '/' . $cacheName . '.html') : unlink($this->cacheDir . '/' . $this->fileName . '.html'); } public function cacheLoad($cacheTime = 10) { if ($cacheTime <= 0) { return false; } $this->cacheTime = $cacheTime * 60; $this->overdue = $this->now - filemtime($this->cacheDir . '/' . $this->fileName . '.html'); if ($this->overdue > $this->cacheTime) { return false; } return require $this->cacheDir . '/' . $this->fileName . '.html'; } } // var_dump($_SERVER); $pageCache = new PageCache(); $pageCache->cacheDir = 'cache'; $pageCache->cacheWirte('hello'); $pageCache->cacheLoad(); var_dump($pageCache->cacheCheck()); // var_dump($pageCache->cacheRemove());