Tested it on thinkphp
print_r("test:",array(1, 2, 3, 4, 5, 6));
var_dump("test1:",array( 1, 2, 3, 4, 5, 6));
I found that the top one is always blank
The bottom one is normal
What is this problem? Please answer
漂亮男人2017-05-16 13:13:27
That is caused by improper use of your function.
The print_r function has two parameters ,
The first parameter is required and is the variable to be printed. For example, "test" (string), 123 (integer), 123.01 (floating point), true (Boolean), etc.;
The second parameter is optional and is a Boolean value. If true, it is not printed, but its output is returned as the result.
<?php
$a = print_r('使用了true,所以我在这里只是变量值咯<br />',true);
print_r('没使用true,直接输出咯<br />');
echo $a;
After running, the results are as follows:
没使用true,直接输出咯
使用了true,所以我在这里只是变量值咯
In short, var_dump prints multiple sets of variable information, print_r prints a set of variable information
淡淡烟草味2017-05-16 13:13:27
print_r($var1,$var2); When $var2 is true, no output will be output; but if your second parameter is an array, will no error be reported? ?
世界只因有你2017-05-16 13:13:27
The second parameter of print_r is of bool type, your usage is wrong.
PHP中文网2017-05-16 13:13:27
print_r does not output information but returns information when the second parameter is true. Your second parameter is a non-empty array and will be implicitly converted to true. If it is an empty array, it will be implicitly converted to false.