类别:FRONTEND / 前端 / 日期:2020-05-07 / 浏览:1832 / 评论:0
echo:输出一个或多个字符串。
print_r():打印关于变量的易于理解的信息(仅返回结果)。
var_dump():显示关于一个或多个表达式的结构信息(返回表达式的类型与值)。
单纯Mark一下,以后要调试数组的时候方便抄。
$arr=array( array('a'=>'1','b'=>'2','c'=>'3'), array('a'=>'11','b'=>'22','c'=>'33'), array('a'=>'111','b'=>'222','c'=>'333') ); $json=json_encode($arr); echo $json; #输出结果 /** [{"a":"1","b":"2","c":"3"},{"a":"11","b":"22","c":"33"},{"a":"111","b":"222","c":"333"}] **/ print_r($json); #打印结果 /** [{"a":"1","b":"2","c":"3"},{"a":"11","b":"22","c":"33"},{"a":"111","b":"222","c":"333"}] **/ var_dump($json); #返回结果 /** string(88) "[{"a":"1","b":"2","c":"3"},{"a":"11","b":"22","c":"33"},{"a":"111","b":"222","c":"333"}]" **/ print_r($arr); #打印结果 /** Array ( [0] => Array ( [a] => 1 [b] => 2 [c] => 3 ) [1] => Array ( [a] => 11 [b] => 22 [c] => 33 ) [2] => Array ( [a] => 111 [b] => 222 [c] => 333 ) ) **/ var_dump($arr); #返回结果 /** array(3) { [0] => array(3) { ["a"] => string(1) "1" ["b"] => string(1) "2" ["c"] => string(1) "3" } [1] => array(3) { ["a"] => string(2) "11" ["b"] => string(2) "22" ["c"] => string(2) "33" } [2] => array(3) { ["a"] => string(3) "111" ["b"] => string(3) "222" ["c"] => string(3) "333" } } **/
版权声明 : 本文未使用任何知识共享协议授权,您可以任何形式自由转载或使用 / Article Is Not Licensed Under Any Creative Commons License, And You May Freely Reprint Or Use It In Any Form
发表评论 / 取消回复