Using PHP to generate static HTML speed Fast class library _php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
Ob_start (); #开启服务器缓存
Include_once ' index.php ';
$ctx =ob_get_contents (); # get Cache
Ob_end_clean (); #清空缓存
$FH =fopen ("index.html", "w+");
Fwrite ($FH, $ctx); # write HTML, generate HTML
Fclose ($FH);

1, Flush: Flush the contents of the buffer, output.
function format: Flush ()
Description: This function is often used and is highly efficient.
2. Ob_start: Open Output buffer
function format: void Ob_start (void)
Note: When the buffer is active, all non-file header information from the PHP program is not sent, but is saved in the internal buffer. In order to output the contents of the buffer, you can use the contents of the Ob_end_flush () or flush () output buffers.
3. Ob_get_contents: Returns the contents of the internal buffer.
Use
function Format: string ob_get_contents (void)
Description: This function returns the contents of the current buffer and returns FALSE if the output buffer is not activated.
4. Ob_get_length: Returns the length of the internal buffer.
How to use: int ob_get_length (void)
Note: This function returns the length of the current buffer, as with ob_get_contents, if the output buffer is not activated. FALSE is returned.
5. Ob_end_flush: Sends the contents of the internal buffer to the browser, and closes the output buffer.
How to use: void Ob_end_flush (void)
Description: This function sends the contents of the output buffer (if any).
6. Ob_end_clean: Delete the contents of the internal buffer and close the internal buffer
How to use: void Ob_end_clean (void)
Description: This function does not output the contents of the internal buffer but deletes it!
7. Ob_implicit_flush: Turn absolute refresh on or off
How to use: void Ob_implicit_flush ([int flag])
Copy CodeThe code is as follows:
///////////////////////////////////////////////////////////////////////////////
//
Zhangshulin-Hui Jia Studio
//
Module name:woods-bhtml.php
Abstract: Generating a static HTML handler end
version:2.0
Date 1006-11-25
Author:woods Zhang
website:http://www.hoojar.com/
Email:hoojar@53.com
Msn:hoojar@hotmail.com
Copyright 1001-1006, Hoojar studio All rights Reserved
//
Copyright 1001-1006, All rights reserved for Hui Jia Studio

The software for free software, allowing use, copy,
Modify and distribute the software and files. Any
Use of this software must place a copy of the The
Above copyright notice. By the Software Huijia Studio
Maintenance, if you have a queries please contact us.
Thank.
//
This software is free software and allows the use, copying, modification and distribution of the software and its documentation.
All copies of the above copyright notice must appear in any place where this software is used. This software is provided by
HPE Studio Maintenance, if you have any questions please contact us. Thank you for using.
//
///////////////////////////////////////////////////////////////////////////////
This file can only be loaded at the end of the program
/*________________ Generating HTML files ______________________beign________________________________*/
if ($make _html)
{
$buffer = Ob_get_flush ();
if ($go _html)//whether to go directly to the HTML file display or PHP read the content output (0:php read Output 1: Direct turn)
{
/*__________ handles the problem of seed size resulting from the creation of HTML files ____________________begin_______________*/
$search = Array (
"/(src=|action=|href=|ajaxread\ () \"/ie ",
"/\.\.\./e",
"/\.\/\./e",
"/\.\.\/http:\/\//ies",
"/\.\.\/#/",
"/\ ' \.\ '/E",
"/\.\.\/javascript:/ies");

$replace = Array (
"' \\1\". /'",
"'..'",
"'.'",
"'/http '",
"#",
"'\'.. \''",
"' javascript: '");
$buffer = Preg_replace ($search, $replace, $buffer);
/*__________ handles the problem of seed size resulting from the creation of HTML files ____________________end_______________*/
}

$fp = fopen (html_file, "w");
if ($FP)
{
Fwrite ($fp, $buffer);
Fclose ($FP);
}
}
/*________________ Generating HTML files ______________________beign________________________________*/
?>

///////////////////////////////////////////////////////////////////////////////
//
Zhangshulin-Hui Jia Studio
//
Module name:woods-thtml.php
Abstract: Generating a static HTML handler header
version:2.0
Date 1006-11-25
Author:woods Zhang
website:http://www.hoojar.com/
Email:hoojar@53.com
Msn:hoojar@hotmail.com
Copyright 1001-1006, Hoojar studio All rights Reserved
//
Copyright 1001-1006, All rights reserved for Hui Jia Studio

The software for free software, allowing use, copy,
Modify and distribute the software and files. Any
Use of this software must place a copy of the The
Above copyright notice. By the Software Huijia Studio
Maintenance, if you have a queries please contact us.
Thank.
//
This software is free software and allows the use, copying, modification and distribution of the software and its documentation.
All copies of the above copyright notice must appear in any place where this software is used. This software is provided by
HPE Studio Maintenance, if you have any questions please contact us. Thank you for using.
//
///////////////////////////////////////////////////////////////////////////////
This file can only be loaded at the beginning of the program
Ob_start ();
/*___________ determines if an HTML file has been generated and jumps to the HTML page if it is generated ___________begin__________*/
$qstring = Isset ($_server["query_string"])? $_server["Query_string"]: "";
if ($qstring)//program adds handle to get request
{
$qstring = str_replace ("=", "", $qstring);
Define ("Html_file", "./h/{$efilename}-{$qstring}.html");
}
Else
{
Define ("Html_file", "./h/{$efilename}.html");
}
if (file_exists (html_file))
{
$LCFT = Filemtime (html_file);//last Create FILE time
if ($LCFT + 3600) > Time ())//Determine if the last HTML file was generated in the past 1 times, if not directly output the file contents
{
if ($show _html)//whether to display in HTML static page (0 is not displayed in HTML display 1 in HTML display)
{
if ($go _html)//whether to go directly to the HTML file display or PHP read the content output (0:php read Output 1: Direct turn)
{
Header ("Location:".) html_file);//Direct turn
}
Else
{
Echo (file_get_contents (html_file));//Read display
}
Exit (0);
}
}
}
/*___________ determines if an HTML file has been generated and jumps to the HTML page if it is generated ___________end__________*/
?>

///////////////////////////////////////////////////////////////////////////////
//
Zhangshulin-Hui Jia Studio
//
Module Name:index.php
Abstract: Home Information
version:1.0
Date 2006-11-7
Author:woods Zhang
website:http://www.hoojar.com/
Cemail:hoojar@163.com
Msn:hoojar@hotmail.com
Copyright 2001-2006, Hoojar studio All rights Reserved
//
Copyright 2001-2006, All rights reserved for Hui Jia Studio

The software for free software, allowing use, copy,
Modify and distribute the software and files. Any
Use of this software must place a copy of the The
Above copyright notice. By the Software Huijia Studio
Maintenance, if you have a queries please contact us.
Thank.
//
This software is free software and allows the use, copying, modification and distribution of the software and its documentation.
All copies of the above copyright notice must appear in any place where this software is used. This software is provided by
HPE Studio Maintenance, if you have any questions please contact us. Thank you for using.
//
///////////////////////////////////////////////////////////////////////////////
Require ("woods-thtml.php");//Generate HTML processing header
if (count ($_get) < 1 && count ($_post) < 1) {require ("woods-thtml.php");} Generating an HTML processing header

Require ("{$exec _file}");//Registry language definition file
foreach ($lang as $key = $value)
{
$ATPL [Strtoupper ($key). " _lang "] = $value;
}
/*____________________________________ list Common sense go up item __________________end_____________________*/
Include ("woods-templates.php");
$TPL = new Woodstpl ("./templates/");
$tpl->require_tpl ("header.html");
$tpl->set_file ();
$tpl->block ("Ebcorp", $scorp);
$tpl->block ("NEWS", $news);

$tpl->block ("PRODUCT", $product);
$tpl->block ("Ebpname_msg", $spname);

$tpl->block ("lore", $lore);
$tpl->require_tpl ("footer.html");
$tpl->parse ($ATPL, true);
$TPL = NULL;
/*________________ Template Operation _________________________end___________________________________*/
Require ("woods-bhtml.php");//Generate HTML processing tail
?>

http://www.bkjia.com/PHPjc/318133.html www.bkjia.com true http://www.bkjia.com/PHPjc/318133.html techarticle Copy the code as follows: Ob_start (); #开启服务器缓存 include_once ' index.php '; $ctx =ob_get_contents (); # get Cache Ob_end_clean (); #清空缓存 $fh = fopen ("index.html", "w+ ...

  • 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.