PHP generates HTML file code _php tutorial

Source: Internet
Author: User
PHP generated HTML file code there are many ways, more commonly used for static use of the method, but we are using the direct generation of pure HTML file PHP code and method

PHP generated HTML file code there are many ways, more commonly used for static use of the method, but we are using the direct generation of pure HTML file PHP code and methods, let's take a look at

The first method is to use the Smary template to generate the form.

Require (' smarty/smarty.class.php ');
$t = new Smarty;
$t->assign ("title", "Hello world!");
$content = $t->fetch ("templates/index.htm");
Here the fetch () is the function that gets the output content, now inside the $content variable, is to display the content
$fp = fopen ("archives/2005/05/19/0001.html", "w");
Fwrite ($fp, $content);
Fclose ($FP);
?>

Another way is to use PHP od_get_contents to generate
Ob_start ();
echo "Hello world!";
$content = Ob_get_contents ();//Get all the contents of the PHP page output
$fp = fopen ("archives/2005/05/19/0001.html", "w");
Fwrite ($fp, $content);
Fclose ($FP);

The third method is to use PHP's natural function fopen to save directly.

http://www.bkjia.com/PHPjc/630487.html www.bkjia.com true http://www.bkjia.com/PHPjc/630487.html techarticle PHP generated HTML file code there are many ways, more commonly used for static use of the method, but we use the following is the direct generation of pure HTML file PHP code and method php generated HTML text ...

  • Related Article

    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.