打印所有已定义的变量和值

时间:2022-12-24 16:49:38
<?php echo ‘<pre>’; print_r(get_defined_vars()); echo ‘</pre>’; ?>

This is just giving me the arrays for defined variables but not priniting out any variables. How can I print values too?

这只是给了我定义变量的数组,而不是输出任何变量。我如何也能打印值?

Also what function can I use to output all the defined variables in this format:

我还可以使用什么函数来输出这种格式的所有已定义变量:

Variable name | Variable Type [int, array, string, bool] | Variable defined on line | Variable defined in script | Variable used times | Variable Value

变量名|变量类型[int, array, string, bool] |变量,定义在脚本|变量中定义的|变量,使用乘以|变量值

2 个解决方案

#1


48  

Have you tried:

你有试过:

var_dump(get_defined_vars());

http://php.net/manual/en/function.var-dump.php

http://php.net/manual/en/function.var-dump.php

The php documentation should help.

php文档应该会有所帮助。

#2


0  

You can make your own debug output, by iterating through the array of returned to display gettype, value and name. However, the where it was defined, how much its been used, you cant do. PHP doesnt work that way

通过遍历返回的数组以显示gettype、value和name,您可以创建自己的调试输出。然而,在定义它的地方,它被使用了多少,你不能这么做。PHP不是那样工作的

#1


48  

Have you tried:

你有试过:

var_dump(get_defined_vars());

http://php.net/manual/en/function.var-dump.php

http://php.net/manual/en/function.var-dump.php

The php documentation should help.

php文档应该会有所帮助。

#2


0  

You can make your own debug output, by iterating through the array of returned to display gettype, value and name. However, the where it was defined, how much its been used, you cant do. PHP doesnt work that way

通过遍历返回的数组以显示gettype、value和name,您可以创建自己的调试输出。然而,在定义它的地方,它被使用了多少,你不能这么做。PHP不是那样工作的