您好,登錄后才能下訂單哦!
<?php function reconstructDump() { $args = func_num_args(); for($i = 0;$i < $args; $i ++) { $param = func_get_arg($i); switch(gettype($param)) { case 'NULL' : echo 'NULL'; break; case 'boolean' : echo ($param ? 'bool(true)' : 'bool(false)'); break; case 'integer' : echo "int($param)"; break; case 'double' : echo "float($param)"; break; case 'string' : dumpString($param); break; case 'array' : dumpArr($param); break; case 'object' : dumpObj($param); break; case 'resource' : echo 'resource'; break; default : echo 'UNKNOWN TYPE'; break; } } } function dumpString($param) { $str = sprintf("string(%d) %s",strlen($param),$param); echo $str; } function dumpArr($param) { $len = count($param); echo "array($len) {\r\n"; foreach($param as $key=>$val) { if(is_array($val)) { dumpArr($val); } else { echo sprintf('["%s"] => %s(%s)',$key,gettype($val),$val); } } echo "}\r\n"; } function dumpObj($param) { $className = get_class($param); $reflect = new ReflectionClass($param); $prop = $reflect->getDefaultProperties(); echo sprintf("Object %s #1(%d) {\r\n",$className,count($prop)); foreach($prop as $key=>$val) { echo "[\"$key\"] => "; reconstructDump($val); } echo "}"; } class MyClass { protected $_name; function test() { echo "hello"; } } $str = "test"; reconstructDump(new MyClass(),$str); echo "\r\n"; $arr2 = array( "1" => "Ddaddad", "one" => array("two" => "Dddd" ), "three" => 1 ); reconstructDump($arr2); reconstructDump(1,true,null); exit;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。