Sep
07
2021
php调试函数总结
作者:
绝缘体.. 发布:
2021-09-07 07:18 分类:
未分类 阅读:
抢沙发
php调试函数总结。
1. echo
打印字符串。
2. print
打印字符串,相比于 echo,只能输出一个变量值,有返回值。
3. print_r
打印变量的值,相比于 print,可以打印数组和对象。
4. var_dump
打印变量的值,包含了变量的值,类型,以及值长度或大小。
5. debug_zval_dump
打印变量的值,这个返回结果和 var_dump 差不多,主要是多了个 refcount,变量的应用数。
6. debug_print_backtrace
debug_print_backtrace — 打印一条回溯。输出类似如下:
#0 c() called at [/tmp/include.php:10] #1 b() called at [/tmp/include.php:6] #2 a() called at [/tmp/include.php:17] #3 include(/tmp/include.php) called at [/tmp/test.php:3]
7. debug_backtrace
产生一条 PHP 的回溯跟踪(backtrace),返回一个包含众多关联数组的 array。返回结果类似如下:
array(2) {
[0]=>
array(4) {
["file"] => string(10) "/tmp/a.php"
["line"] => int(10)
["function"] => string(6) "a_test"
["args"]=>
array(1) {
[0] => &string(6) "friend"
}
}
[1]=>
array(4) {
["file"] => string(10) "/tmp/b.php"
["line"] => int(2)
["args"] =>
array(1) {
[0] => string(10) "/tmp/a.php"
}
["function"] => string(12) "include_once"
}
}
微信扫一扫,打赏作者吧~