php 控制输出,输出控制类_php

news/2024/9/5 19:31:02

/**

*

*  作者: 徐祖宁 (唠叨)

*  邮箱: czjsz_ah@stats.gov.cn

*  开发: 2002.07

http://www.gaodaima.com/46455.html输出控制类_php

*

*

*  类: outbuffer

*  功能: 封装部分输出控制函数,控制输出对象。

*

*  方法:

*  run($proc)                运行php程序

*    $proc     php程序名

*  display()                 输出运行结果

*  savetofile($filename)     保存运行结果到文件,一般可用于生成静态页面

*    $filename 文件名

*  loadfromfile($filename)   装入保存的文件

*    $filename 文件名

*

*  示例:

*  1.

*  require_once "outbuffer.php";

*  $out = new outbuffer();

*  $out->run("test.php");

*  $out->display();

*

*  2.

*  require_once "outbuffer.php";

*  require_once "outbuffer.php";

*  $out = new outbuffer("test.php");

*  $out->savetofile("temp.htm");

*

*  3.

*  require_once "outbuffer.php";

*  $out = new outbuffer();

*  $out->loadfromfile("temp.htm");

*  $out->display();

*

*/

class outbuffer {

var $length;

var $buffer;

function outbuffer($proc="") {

$this->run($proc);

}

function run($proc="") {

ob_start();

include($proc);

$this->length = ob_get_length();

$this->buffer = ob_get_contents();

$this->buffer = eregi_replace("/r?/n","/r/n",$this->buffer);

ob_end_clean();

}

function display() {

echo $this->buffer;

}

function savetofile($filename="") {

if($filename == "") return;

$fp = fopen($filename,"w");

fwrite($fp,$this->buffer);

fclose($fp);

}

function loadfromfile($filename="") {

if($filename == "") return;

$fp = fopen($filename,"w");

$this->buffer = fread($fp,filesize($filename));

fclose($fp);

}

}

?>

欢迎大家阅读《输出控制类_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码

原创文章,转载请注明: 转载自搞代码

e7ce419cf2d6ad34d01da2ceb8829eed.png

微信 赏一包辣条吧~

023a57327877fb4402bcc76911ec18ea.png

支付宝 赏一听可乐吧~


http://www.niftyadmin.cn/n/547422.html

相关文章

telnet命令

telnet命令可以缩写。支持的命令为: c - close 关闭当前连接 d - display 显示操作参数 o - open hostname [port] 连接到主机名称(默认端口 23)。 q - quit 退出 telnet set - set …

php7.2.9 redis,CentOS7为php7.2安装php-redis扩展

先下载phpredis-developcd /tmpwget https://codeload.github.com/phpredis/phpredis/zip/develop安装unzip、zip解压工具yum -y install unzip zip解压unzip develop解压后会多了个phpredis-develop的目录。进入目录cd phpredis-develop安装phpize模块yum -y install php-deve…

CentOS 6 yum源   更换成阿里云扩展源

第一种: 1、rm -rf /etc/yum.repos.d/* (执行此操作的时候记得事先装好wget 不然 你就得挂载光盘用rpm装wget了。)2、wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo http://mirrors.aliyun.…

php study是什么,phpstudy是什么框架

phpstudy是什么框架?phpstudy不是什么框架,而是一个PHP调试环境的程序集成包。该程序包集成最新的ApachePHPMySQLphpMyAdminZendOptimizer,一次性安装,无须配置即可使用,是非常方便、好用的PHP调试环境。该程序不仅包括…

可重入函数与线程安全的区别与联系

1、可重入函数1)举例说明:main函数调用insert函数向一个链表head中插入节点node1,插入操作分为两步,刚做完第一步的时候,因为硬件中断使进程切换到内核,再次回用户态之前检查到有信号待处理,于是切换到sighandler函数sighandler也调用insert函数向同一个…

sql 外围应用程序配置

--开启 即席远程查询execsp_configure show advanced options,1reconfigureexecsp_configure Ad Hoc Distributed Queries,1reconfigure--关闭 即席远程查询execsp_configure Ad Hoc Distributed Queries,0reconfigureexecsp_configure show advanced options,0reconfigure--开…

php 万能字符串截取,php怎么实现字符串截取?

php怎么实现字符串截取?1、使用substr函数substr函数实现截取字符串语法:string substr(string $string,int $start [, int $length ])说明:如果省略length,则返回从start至字符结尾之间的字符串;如果start或length为负…

让WTK2.5.2自带的模拟器支持全屏显示和正常字体

WTK2.5.2自带的模拟器不能全屏显示,即使把Canvas.fullScreenMode设置为true也不能全屏,始终在上边都有一条去不掉的状态栏。 并且,模拟器的字体非常难看,8号字体,非常小,严重影响调试。 研究了一下&#xf…