How does PHP execute a dynamic page to cache and generate static pages?

Source: Internet
Author: User
Tags php source code
How does PHP execute a dynamic page to cache and generate static pages?
In ASP, the XMLHTTP object's open method is usually opened to execute a dynamic page, then the static HTML code generated after the dynamic page execution can be saved by a ADODB.stream object and then written to a text file.

In PHP, you can open the cache with Ob_start, let the string be written to the cache first, and then write the contents of the cache to a text file, the question is, how does PHP execute a dynamic page, in some articles, with the header ("location:adminnews.php") To execute a dynamic page, but I tried, so he only goes to this dynamic page, and does not output the content of the dynamic page to the cache, my code is this, I want to adminnews.php execution results (generated HTML code) all write to jb51.html, what should be done
Ob_start (); Open buffer
echo "hello\n"; Output
Header ("location:adminnews.php"); redirect the browser to index.php

$cacheStr =ob_get_contents ();
$handle =fopen ("jb51.html", "w");
Fwrite ($handle, $CACHESTR);
Ob_clean ();
?> generating a static page

Share to:


------Solution--------------------
Ob_start (); Open buffer
echo "hello\n"; Output
Include ("adminnews.php"); Load and run

$cacheStr =ob_get_contents ();
$handle =fopen ("jb51.html", "w");
Fwrite ($handle, $CACHESTR);
Ob_clean ();
------Solution--------------------
With $wstr=file_get_contents (' http://www.baidu.com '); This function goes to execute a URL address.
------Solution--------------------
References:
file_get_contents can get the results of adminnews.php execution.

I tried not to Ah, using this to get to the adminnews.php source code, rather than adminnews.php execution results, I want to be executed after the generated HTML code, not the original PHP code AH.
Ob_start (); Open buffer
echo "hello\n"; Output
$cacheStr =file_get_contents ("adminnews.php"); //

$handle =fopen ("jb51.html", "w");
Fwrite ($handle, $CACHESTR);
Ob_clean ();
?>


How do you access it through the browser, file_get_contents fill that address inside
  • 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.