"Turn" the difference between Php:echo, print, Print_r, sprintf, Var_dump
-Echo
is a command and cannot return a value. Echo can be followed by a number of parameters, separated by semicolons, such as:
Echo $myvar 1 ; Echo 1 , 2 , $myvar , "Bold" ; |
-Print
is a function that returns a value that can have only one parameter.
-printf
function to format the text for later output, such as:
$name = "Hunte" ; $age = - ; printf (%s%d",$name,$age ); |
-sprintf
Similar to printf, but does not print, but returns formatted text, the rest is the same as printf.
-Print_r
Print_r are typically used to print information about variables, which are typically used in debugging.
Print_r (true) ; //Output 1 Print_r (false) ; //No output Print_r (null) ; //No output |
-Var_dump
Var_dump This function displays structure information about one or more expressions, including the type and value of the expression.
Var_dump (true) ; //output bool (TRUE) Var_dump (false) ; //bool (FALSE) Var_dump (null) ; //bool (NULL) |
The difference between var_dump () and Print_r ():
Var_dump returns the type and value of the expression and Print_r only returns the result, which is easier to read than the debug code using Var_dump.
< PHP >