How to generate an HTML file with PHP

zhaozj2021-02-12  138

How to generate an HTML file in PHP 2004-06-27 Excerpt from: http://xjtusky.net/Article/Article.php/526

How to generate an HTML file with PHP?

Summarize one

After the post is issued, you get the enthusiastic response and help of netizens. In order to return the villagers, they will organize the effective post.

1, Matrix @ two_max post:

$ fp = fopen ("Temple T.html", "A");

IF ($ fp) {

$ FUP = FREAD ($ FP, FileSize ("Temple T.html");

$ fp2 = fopen ("html.shtml", "w");

IF ($ FWRITE ($ FP2, $ FUP) {

$ FCLOSE ($ fp);

$ fcolse ($ fp2);

DIE ("Write Template Success");

} else {

Fclose ($ fp);

DIE ("Write Template Fails!");

}

}

?>

Simply write a template into a file is html.html

2, Matrix @ two_max posts:

This is a template file, you need to provide template files like Temple T.html on the server.

Does not talking about template?

Of course, you can also generate a static page. Just open the template for a step, replace the process of content

$ Content = "This is a test file for static generation web pages, the file name is html.html ";

$ fp = fopen ("html.shtml", "w");

IF (FWRITE ($ FP, $ Content) {

Fclose ($ fp);

DIE ("Write Template Success");

} else {

Fclose ($ fp);

DIE ("Write Template Fails!");

}

?>

3, Rebol posted:

$ S_FNAME = "93e.php";

$ O_FNAME = "93e.htm";

Ob_end_clean ();

Ob_start ();

INCLUDE ($ s_fname);

$ length = ob_get_ley ();

$ buffer = ob_get_contents ();

$ buffer = EREGI_REPLACE ("R", ", $ buffer;

Ob_end_clean ();

$ fp = fopen ($ O_FNAME, "W ");

FWRITE ($ FP, $ Buffer);

Fclose ($ fp);

?>

This will

93e.php is transformed into static HTML files

It is important to pay attention to the file to be converted.

OB_END_CLEAN (); and ob_start (); statement.

And the directory needs to be written.

转载请注明原文地址:https://www.9cbs.com/read-7441.html

New Post(0)