如何以编程方式烘烤静态HTML文件? [英] PHP - How to programmatically bake out static HTML file?

查看:101
本文介绍了如何以编程方式烘烤静态HTML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何以编程方式将动态PHP文件转换为静态HTML文件,显然将所有动态PHP相关值作为静态HTML进行烘焙?

解决方案

ob_start();
?>

在脚本的最后,放置这个:

 <?php 
$ myStaticHtml = ob_get_clean();
//现在你的静态页面在$ myStaticHtml
?>

输出缓冲引用:


http://php.net/ manual / zh / book.outcontrol.php

http://www.php.net/manual/en/function.ob-start.php

http://www.php.net/manual/en/function.ob-end-clean.php



How do you programmatically convert a dynamic PHP file into a static HTML file, that would obviously have all dynamic PHP-related values baked in as static HTML?

解决方案

As the beginning of your script place this:

<?php
    ob_start();
?>

At the very end of the script, place this:

<?php
    $myStaticHtml = ob_get_clean();
    // Now you have your static page in $myStaticHtml
?>

Output buffering reference here:

http://php.net/manual/en/book.outcontrol.php
http://www.php.net/manual/en/function.ob-start.php
http://www.php.net/manual/en/function.ob-end-clean.php

这篇关于如何以编程方式烘烤静态HTML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆