php不为人知的函数register_shutdown_function的用法

void register_shutdown_function ( callback $function [, mixed $parameter [, mixed $... ]] )

说明 :注册一个函数名,当脚本执行完成后再调用该函数

例子:

 
register_shutdown_function ('page_log');
 
function hd_write_log ($str,$type='perf') {
	$dirname = ROOT_PATH.'/logs/'.date('Ym');
	if (!is_dir ($dirname))	{
		@mkdir ($dirname ,0777);
	}
	$filename = $dirname.'/'.date ('Ymd').'_'.$type.'.log';
	$handle = fopen ($filename ,'a+') ;
	if ($handle) {
		fwrite ($handle ,$str."\r\n");
		fclose ($handle);
	}
 
}

Leave Your Comment

Your email will not be published or shared. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

*
请输入图片中的字符以验证你并非垃圾机器人. 点击图片收听验证码的语音版.
点击这里收听此验证码的语音版本