How does PHP execute a dynamic page to the cache and then generate a static page? in ASP, the open method of XMLHTTP object is usually used to open a dynamic page for execution, the static html code generated after the dynamic page is executed can use an adodb. the stream object is saved and then written to a text file. In PHP, you can use ob_start & nbsp; to create PHP. how can I execute a dynamic page into the cache and then generate a static page?
In ASP, the open method of the XMLHTTP object is usually used to open a dynamic page for execution. the static html code generated after the dynamic page is executed can be a adodb. the stream object is saved and then written to a text file.
In PHP, you can use ob_start to open the cache, so that the string is first written to the cache, and then the content in the cache is written to a text file. The problem is, how does PHP execute a dynamic page, in some articles, we use header ("location: adminnews. what should I do in php "example?
Ob_start (); // open the buffer
Echo "Hello \ n"; // output
Header ("location: adminnews. php"); // redirects the browser to index. php.
$ CacheStr = ob_get_contents ();
$ Handle = fopen ("jb51.html", "w ");
Fwrite ($ handle, $ cacheStr );
Ob_clean ();
?> Generate static pages to share:
------ Solution --------------------
Ob_start (); // open the 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 --------------------
Use $ wstr = file_get_contents ('http: // www.baidu.com '). you can use this function to execute a URL address.
------ Solution --------------------
Reference:
File_get_contents can get the result of adminnews. php execution.
I tried it. I can't use it to get adminnews. php source code, rather than adminnews. the php execution result is the html code generated after execution, rather than the original php code ..
Ob_start (); // open the buffer
Echo "Hello \ n"; // output
$ CacheStr = file_get_contents ("adminnews. php ");//
$ Handle = fopen ("jb51.html", "w ");
Fwrite ($ handle, $ cacheStr );
Ob_clean ();
?>
How did you access it through the browser? in file_get_contents, enter the address