php print_r prints a blank
为情所困
为情所困 2017-05-16 13:11:27
0
5
644

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

为情所困
为情所困

reply all(5)
漂亮男人

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

曾经蜡笔没有小新

http://php.net/manual/en/func...
See the manual

淡淡烟草味

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? ?

世界只因有你

The second parameter of print_r is of bool type, your usage is wrong.

Ty80

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template