Use the ob function and file_put_contents in php to generate a simple static page class

WBOY
Release: 2016-08-08 09:25:44
Original
1251 people have browsed it
key=$key; $this->html(); return ob_end_clean(); } public function get($key){ $filename =$this->getFilename($key); if(!$filename || !file_exists($filename)){return false;} include($filename); return true; } public function html(){ $filename =$this->getFilename($this->key); if(!$filename) {return false;} return file_put_contents($filename,ob_get_contents()); } public function getFilename($key){ $filename =($this->ismd5==true)?md5($key):$key; if(!is_dir($this->htmlpath)){return false;} return $this->htmlpath.'/'.$filename.$suffix; } } /** * 使用 */ //实例化对象 $htmlObj = new StaticHtml(); //生成静态页面 $htmlObj->start(); $htmlObj->end(100); //引用静态页面 $htmlObj->get(100); ?>
Copy after login

The above introduces the class that uses the ob function and file_put_contents in PHP to generate a simple static page, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!