说明
dump方法,用于输出变量的信息到浏览器查看
语法
dump($var, $echo=true, $label=null)
参数解析
参数 | 描述 |
---|---|
var(必须) | 要输出的变量,支持所有变量类型 |
echo(可选) | 是否直接输出,默认为true,如果为false则返回但不输出 |
label(可选) | 变量输出的label标识,默认为空 |
示例
dump($memberList,$echo=true,$label=null);
输出
array (size=4) 0 => array (size=3) 'id' => int 0 'name' => string 'thinkphp' (length=8) 'score' => int 1 1 => array (size=3) 'id' => int 4 'name' => string 'zhangsan4' (length=9) 'score' => int 0 2 => array (size=3) 'id' => int 5 'name' => string 'zhangsan5' (length=9) 'score' => int 0 3 => array (size=3) 'id' => int 6 'name' => string 'zhangsan6' (length=9) 'score' => int 0
注意
echo参数为false 则返回要输出的字符串
示例
$str = dump($memberList,$echo=false,$label=null); print_r($str);
输出
array (size=4) 0 => array (size=3) 'id' => int 0 'name' => string 'thinkphp' (length=8) 'score' => int 1 1 => array (size=3) 'id' => int 4 'name' => string 'zhangsan4' (length=9) 'score' => int 0 2 => array (size=3) 'id' => int 5 'name' => string 'zhangsan5' (length=9) 'score' => int 0 3 => array (size=3) 'id' => int 6 'name' => string 'zhangsan6' (length=9) 'score' => int 0