A scheme to change an existing dynamic news page into a static page with PHP
Source: Internet
Author: User
Dynamic | static | page Excuse me, when I browse a Web page, I want to create a corresponding static Web page in the server to facilitate the call, how to deal with better?
My program was previously written without this feature. So I think there is no better than a lot of changes to the original program in the case of the implementation of this function.
You can judge in the Diplay whether there is a file name with the corresponding ID in the corresponding directory (this assumes that the file is an ID number +html that is 1.html,2.html,...)
You judge $id. " HTML "whether the file exists on the server, if there is a direct jump to this page, if not exist to create (build justice with a function to create, so that the page changes is not much, such as createhtml ($_get[' id ')", as for this function how to write, I think you should know) and then jump
-------------------------------------------------
Reply Person: Ice_berg16 (the Scarecrow Seeking the Dream) (Samsung (advanced)) Reputation: 125 2006-2-28 21:33:13
Suppose you display the page of the article as
Shownews.php?id=34
Then you can do that.
Ob_start ();
Your normal program code.
$html =ob_get_contents ();
Ob_end_clean ();
$fp =fopen ($_get[' id '). ". HTM "," w ");
Fwrite ($fp, $html);
Fclose ($FP);
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