ITeye博客

个人小工具mylog最新

lxmgfd · 2018-01-27 21:51 · php · 互联网 · PHP · Markdown



<?php 
function mylog($word = '',$var=array(), $log_name='Log', $log_path=ROOT_PATH."data/log/") 
{
	
	$output = "----------------------------------------------------------------------------------------------------\n";
	
	$output .= strftime("%Y%m%d %H:%M:%S", time()) . "    " ;
	$output .= $word."\n" ;
	if(!empty($var)){
		$output .= print_r($var, true)."\n";
	}
	$output.="\n";

	if(!is_dir($log_path)){
		@mkdir($log_path, 0777, true);
	}
	
	file_put_contents($log_path . $log_name . "_".strftime("%Y%m%d", time()).".txt", $output, FILE_APPEND | LOCK_EX);
}


?>


在项目中引入mylog.php, 即可使用。使用方式:

echolog(数据源,'文件名','文件路径');

如有不足之处, 欢迎留言指导

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。