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; }} /** * Use *///to instantiate an object $htmlobj = new statichtml ();//Generate Static page $htmlobj->start (); $htmlObj->end (100);//reference static page $htmlobj- >get (100);? >
The above describes the use of the OB function in PHP and file_put_contents to generate a simple static page class, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.