[Convert] the difference between PHP: echo, print, print_r, sprintf, and var_dump-echo is a command and cannot return a value. Echo can be followed by multiple parameters separated by semicolons, such as echo $ myvar1; echo1, 2, $ myvar, & lt; B & gt; bold & lt; B & gt;-print is a function. one value can be returned and only one parameter is allowed. -Pr [to] PHP: differences between echo, print, print_r, sprintf, and var_dump
-Echo
It is a command and cannot return values. Echo can be followed by multiple parameters separated by semicolons, for example:
echo $myvar1;echo 1,2,$myvar,"bold"; |
-Print
Yes. one value can be returned and only one parameter is allowed.
-Printf
Function to format and output the text, for example:
$name="hunte";$age=25;printf("my name is %s, age %d", $name, $age); |
-Sprintf
Similar to printf, but not printed, the formatted text is returned. Others are the same as printf.
-Print_r
Print_r is usually used to print information about variables, which is usually used in debugging.
Print_r (true); // output 1print_r (false); // no output print_r (null); // no output |
-Var_dump
Var_dump this function displays the structure information about one or more expressions, including the expression type and value.
Var_dump (true); // output bool (true) var_dump (false); // bool (false) var_dump (null); // bool (null) |
Differences between var_dump () and print_r:
Var_dump returns the expression type and value while print_r returns only the result, which is easier to read than using var_dump in debugging code.
<PHP>