一个安全的快速写日志的函数
p 一个安全的快速写日志的函数. /p
一个安全的快速写日志的函数.
<?php /** * 直接记录日志 * @param <type> $lvevel * @param string $level * http://www.phpqee.com */ function Write($msg, $level) { $arr_level = explode(',', YUC_LOG_TYPE); if (in_array($level, $arr_level)) { $record = date('Y-m-d H:m:s') . " >>> " . number_format(microtime(TRUE), 5, ".", "") . ' ' . " : " . $level . "\t" . $msg; $base = M_PRO_DIR . "/Log"; $dest = $base . "/" . date("YmdH", time()) . 'log.php'; if (!file_exists($dest)) { @mkdir($base, 0777, TRUE); @file_put_contents($dest, "<?php die('Access Defined!');?>\r\n", FILE_APPEND); } if (file_exists($dest)) { @file_put_contents($dest, $record . "\r\n", FILE_APPEND); } } }
- 上一篇:统计代码行数和过滤注释
- 下一篇:统一获取设置get和post数据的类
精彩图集
精彩文章