輸出控制類
更新時(shí)間:2006年10月09日 00:00:00 作者:
<?php
/**
*
* 作者: 徐祖寧 (嘮叨)
* 郵箱: czjsz_ah@stats.gov.cn
* 開(kāi)發(fā): 2002.07
*
*
* 類: outbuffer
* 功能: 封裝部分輸出控制函數(shù),控制輸出對(duì)象。
*
* 方法:
* run($proc) 運(yùn)行php程序
* $proc php程序名
* display() 輸出運(yùn)行結(jié)果
* savetofile($filename) 保存運(yùn)行結(jié)果到文件,一般可用于生成靜態(tài)頁(yè)面
* $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);
}
}
?>
/**
*
* 作者: 徐祖寧 (嘮叨)
* 郵箱: czjsz_ah@stats.gov.cn
* 開(kāi)發(fā): 2002.07
*
*
* 類: outbuffer
* 功能: 封裝部分輸出控制函數(shù),控制輸出對(duì)象。
*
* 方法:
* run($proc) 運(yùn)行php程序
* $proc php程序名
* display() 輸出運(yùn)行結(jié)果
* savetofile($filename) 保存運(yùn)行結(jié)果到文件,一般可用于生成靜態(tài)頁(yè)面
* $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);
}
}
?>
相關(guān)文章
php中文本數(shù)據(jù)翻頁(yè)(留言本翻頁(yè))
php中文本數(shù)據(jù)翻頁(yè)(留言本翻頁(yè))...2006-10-10php面向?qū)ο笕ヂ?(十六) 對(duì)象的串行化
有時(shí)候需要把一個(gè)對(duì)象在網(wǎng)絡(luò)上傳輸,為了方便傳輸,可以把整個(gè)對(duì)象轉(zhuǎn)化為二進(jìn)制串.2009-09-09利用PHP實(shí)現(xiàn)與ASP Banner組件相似的類
利用PHP實(shí)現(xiàn)與ASP Banner組件相似的類...2006-10-10php array_map()數(shù)組函數(shù)使用說(shuō)明
函數(shù)array_map()函數(shù):多數(shù)組回調(diào)函數(shù)---將回調(diào)函數(shù)作用到給定數(shù)組的單元上2011-07-07PHP數(shù)據(jù)庫(kù)開(kāi)發(fā)知多少
PHP數(shù)據(jù)庫(kù)開(kāi)發(fā)知多少...2006-10-10nginx+php-fpm配置文件的組織結(jié)構(gòu)介紹
nginx+php-fpm配置文件的組織結(jié)構(gòu)介紹,需要的朋友可以參考下2012-11-11