How to use PHP to generate HTML files

Source: Internet
Author: User
Generate HTML

How do I generate HTML files in PHP?
Summarize a
Post issued, get the enthusiastic response of netizens and help, in return for the villagers, special to the effective replies
1,matrix@two_max's Posts:
<?php
$fp = fopen ("templets.html", "a");
if ($fp) {
$fup = Fread ($fp, FileSize ("templets.html"));
$FP 2 = fopen ("html.shtml", "w");
if ($fwrite ($fp 2, $fup)) {
$fclose ($FP);
$fcolse ($fp 2);
Die ("Write template succeeded");
} else {
Fclose ($FP);
Die ("Write template failed!");
}
}
?>
Simply write the template into a file as a html.html


2,matrix@two_max's Posts:
This is the template file that you need to provide on the server templets.html such a template file

No templates to talk about what to build?

Of course, you can also generate a static page like this. Just one less step. The process of opening a template, replacing content
<?php
$content = "This is a static generated Web page test file, file name <font color= #ff0000 >html.html</font>";
$fp = fopen ("html.shtml", "w");
if (fwrite ($FP, $content)) {
Fclose ($FP);
Die ("Write template succeeded");
} else {
Fclose ($FP);
Die ("Write template failed!");
}
?>


3,rebol's Posts:
<?php
$s _fname = "93e.php";
$o _fname = "93e.htm";
Ob_end_clean ();
Ob_start ();
Include ($s _fname);
$length = Ob_get_length ();
$buffer = Ob_get_contents ();
$buffer = Eregi_replace ("R", "", $buffer);
Ob_end_clean ();

$fp = fopen ($o _fname, "w+");
Fwrite ($fp, $buffer);
Fclose ($FP);
?>

So we can put
93e.php into a static HTML file.
Note that the file to be converted cannot have
Ob_end_clean (); and Ob_start (); statement.
And the directory must have write permission.



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.