PHP 调试和异步调试工具类

function gddebug() {
	$arrays = func_get_args ();
	echo "n<pre>";
	foreach ( $arrays as $value ) {
		if (is_array ( $value ) || is_object ( $value )) {
			ksort ( $value );
			echo htmlspecialchars ( print_r ( $value, true ) ) . "rn";
		} elseif (is_string ( $value )) {
			echo "string(" . strlen ( $value ) . ") "" . htmlspecialchars ( $value ) . ""rn";
		} else {
			var_dump ( $value );
		}
	}
	echo "</pre>";
}

 

异步调试工具类

function gdsyndebug() {
	$arrays = func_get_args ();
	$filename = dirname ( __FILE__ ) . "/gdsyndebug.txt";
	file_put_contents ( $filename, "===================" . date ( "Y-m-d H:i:s" ) . "====n", FILE_APPEND );
	file_put_contents ( $filename, 'url http://' . $_SERVER ['HTTP_HOST'] . $_SERVER ['PHP_SELF'] . "n", FILE_APPEND );
	foreach ( $arrays as $value ) {
		if (is_array ( $value ) || is_object ( $value )) {
			ksort ( $value );
			file_put_contents ( $filename, print_r ( $value, true ) . "n", FILE_APPEND );
		} elseif (is_string ( $value )) {
			file_put_contents ( $filename, "string(" . strlen ( $value ) . ") "" . $value  . ""n", FILE_APPEND );
		} else {
			file_put_contents ( $filename, var_export ( $value, true ) . "n", FILE_APPEND );
		}
	}
}

 

转发请注明出处http://blog.martoo.cn
如有漏缺,请联系我 QQ 243008827

《PHP 调试和异步调试工具类》有1个想法

  1. Hey There. I found your blog using msn. This is a very well written article. I’ll be sure to bookmark it and come back to read more of your useful info. Thanks for the post. I will definitely comeback.

发表评论

电子邮件地址不会被公开。 必填项已用*标注