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.