Class for generating simple static pages using the OB function and file_put_contents in PHP

Source: Internet
Author: User
 
  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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.