php 调试信息输出到txt,写一个把调试信息输出到磁盘文件的DEBUG程序

/* usage:

write in:

ZFDemo_Log::log("PHP extensions loaded = /n    " . implode("/n    ", $extensions));

or:

ZFDemo_Log::log("The '$ext' extension is required, but not currently loaded by php.");

ZFDemo_Log::log("Zend_Session.ini=" . print_r($sessionConfig->toArray(), true));

output:

ZFDemo_Log::show();

require_once('zfdemo_log.php');

*/

class ZFDemo_Log

{

// very simple running log of "debug/" messages to highlight inner workings of demo

public static $log = '';

/**

* Accumulate log messages, but also append them to a running log file for easy viewing.

*/

public static function log($msg, $before = null)

{

static $flushed = false;

if ($before) {

self::$log = "$msg/n" . self::$log;

} else {

self::$log .= "$msg/n";

}

$logfile = 'log.txt';

// performance is not an issue, so just sync to disk everytime

if (isset($logfile)) {

if ($flushed) {

file_put_contents($logfile, "$msg/n", FILE_APPEND);

} else {

file_put_contents($logfile, self::$log);

}

$flushed = true;

}

}

/*

* Useful if you modify the demo, and need to quickly see the debug log in your browser.

*/

public static function show()

{

echo "

ZF Demo Debug Log/n/n
";

echo htmlentities(self::$log, ENT_QUOTES, 'UTF-8');

echo '

';

}

public static function get()

{

return self::$log;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值