下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、The train of thought of the theme PHP gen erate static HTML pages is the PHP script returns HTML in formatio n is writte n to a.Html or.Htm file1php生成html大致可以用两种方法,第一种使用模板,第二种方法使用ob函数。1php HTML can be gen erated by two methods, the first use of the template, sec ond methods of using ob fun cti on.2第
2、一种方法:使用模板2 the first method: using a template我习惯用的是smarty模板,smarty模板中有一个获取输出内容的函数fetch(),利用这个方法可以将获取的内容写入到html文件中。I used to use Smarty templates, one to get the output function fetch (Smarty template), this method can be used to write the content to the HTML file.这是一个简易的执行代码,如下:This is a simple code
3、 executi on, as follows:require('smarty/;-Require ('smarty/; China$t = new Smarty;-$t = new Smarty;$t->assig n("title","Hello World!");-$t->assig n ("title", "Hello World!");$content = $t->fetch("templates/index.htm");-$content = $t-
4、>fetch ("templates/in dex.htm");$fp = fope n("./0001.html", "w");-$fp = fope n ("./0001.html", "W");fwrite($fp, $content);-Fwrite ($fp, $content); Ch ina fclose($fp);-Fclose ($fp); Chi na3第二种方法:使用ob系列函数3 sec ond methods: using ob series function用到
5、的 ob 系列函数有:ob_start(), ob_end_flush(), ob_get_content()。其中 ob_start()是打开浏 览器缓冲区的意思,所有来自PHP程序的非文件头信息均不会发送,而是保存在内部缓冲区,直到使用了 ob_end_flush()。ob_get_contents()这个函数的作用是获取缓冲区的内容,相 当于上面的那个 fetch()。OB series function: ob_start (), ob_e nd_flush (), ob_get_c onten t (). The ob_start () is to ope n the browser
6、 buffer means, sending all from the PHP program of non file header in formati on is not, but stored in an internal buffer, until the use of ob_end_flush (). (ob_get_contents) this function to obta in the contents of the buffer, the fetch is equivale nt to (above).写的一个简易的执行代码如下:A simple executable code writte n as follows:ob_start();-Ob_start (Chi na)echo "Hello World!"-Echo "Hello World!"$content = ob_get_c onten ts();$content = ob_get_c ontents ();$fp = fope n("./0002.html", "w");-$fp = fope n ("./000
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 村干部公务员考试试题及答案
- 2026年银行业专业人员中级职业资格考试(专业实务风险管理)模拟题库及答案商洛
- 小学数学《鸡兔同笼问题》课件
- 屋面通风气楼安装施工方案
- 小班下册期中试卷及答案
- 小学防溺水工作实施方案
- 小学成绩分析管理方案
- 象棋高考题目及答案
- 企业网络安全防护与应急处置预案
- 相交线的5道题目及答案
- 2023-2024学年福建省厦门市高一下学期7月期末质量检测生物试题(解析版)
- 出血、血肿应急预案
- TCPAPE 01-2024 无菌药品生产污染控制策略技术指南
- 学习《吴军阅读与写作》 (50讲 )
- 《决胜B端:驱动数字化转型的产品经理》札记
- 国家开放大学专科《管理英语2》一平台机考真题及答案(第二套)
- (正式版)SH∕T 3541-2024 石油化工泵组施工及验收规范
- 冶金物理化学课件
- 美国西南航空公司案例课件
- 分户验收发言稿
- 电子厂7S推动办法
评论
0/150
提交评论