ECHO is a PHP statement, print and Print_r are functions, statements have no return value, and functions can have return values (even if they are not used)
Print () only prints the value of a simple type variable (such as int,string)
Print_r () can print out the values of complex type variables (such as arrays, objects)
echo outputs one or more strings
Print--Output a string
Description
int print (string arg)//return value is cosmetic
print "Hello friend";
You can do these things
Copy Code code as follows:
$name =print "Nihao \";
$STR = ' Test print value is $name. ';
Eval_r ("\ $print =\" $str "; " );
Echo $print;
Print_r--Print easy to understand information about variables.
BOOL Print_r (mixed Expression_r [, BOOL Return])//Returns the value is Boolean, the parameter is a mix type, can be a string, shaping, array, object class Print_r () to display information about a variable easily understandable. If a string, integer, or float is given, the variable value itself is printed. If you give an array, the keys and elements will be displayed in a certain format. object is similar to an array.
Print_r () Moves the pointer to the last edge of the array.
You can
Copy Code code as follows:
Print_r (str);
Print_r (int);
Print_r (array);
Print_r (obj);
You can also use Var_dump Var_export
echo--output one or more strings
Description
void Echo (String arg1 [, String ...])//return value is NULL
echo "Hello", "friend";
Summarize:
The functions of ECHO and print are essentially the same in PHP (output), but there is a slight difference between the two. echo output does not return a value, but print has a return value that returns Flase when its execution fails. So it can be used as a normal function, such as executing the following code, the value of the variable "will be 1."
$r = print "Hello world";
This means that print can be used in some complex expressions, while Echo is not. However, because the Echo statement does not require any numeric values to be returned, the Echo statement in the code is more efficient to run than the print statement.
ECHO has no return value; Print has a return value, and print's return value is always 1.