search
Homephp教程PHP源码php生成静态文件

php生成静态文件

May 25, 2016 pm 05:13 PM

php生成静态文件

ob_start();#开启服务器缓存 
include_once 'Index.php'; 
$ctx=ob_get_contents();#获取缓存 
ob_end_clean();#清空缓存 
$fh=fopen("index.html","w+"); 
fwrite($fh,$ctx);#写入html,生成html 
fclose($fh); 
/* 
1、Flush:刷新缓冲区的内容,输出。 
函数格式:flush() 
说明:这个函数经常使用,效率很高。 
2、ob_start :打开输出缓冲区 
函数格式:void ob_start(void) 
说明:当缓冲区激活时,所有来自PHP程序的非文件头信息均不会发送,而是保存在内部缓冲区。
为了输出缓冲区的内容,可以使用ob_end_flush()或flush()输出缓冲区的内容。 
3 、ob_get_contents :返回内部缓冲区的内容。 
使用 
函数格式:string ob_get_contents(void) 
说明:这个函数会返回当前缓冲区中的内容,如果输出缓冲区没有激活,则返回 FALSE 。 
4、ob_get_length:返回内部缓冲区的长度。 
使用方法:int ob_get_length(void) 
说明:这个函数会返回当前缓冲区中的长度;和ob_get_contents一样,如果输出缓冲区没有激活。则返回 FALSE。 
5、ob_end_flush :发送内部缓冲区的内容到浏览器,并且关闭输出缓冲区。 
使用方法:void ob_end_flush(void) 
说明:这个函数发送输出缓冲区的内容(如果有的话)。 
6、ob_end_clean:删除内部缓冲区的内容,并且关闭内部缓冲区 
使用方法:void ob_end_clean(void) 
说明:这个函数不会输出内部缓冲区的内容而是把它删除! 
7、ob_implicit_flush:打开或关闭绝对刷新 
使用方法:void ob_implicit_flush ([int flag]) 
*/

以上就是php生成静态文件的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use