Welcome to the Linux community forum and interact with 2 million technical staff to access echo. The difference between print is that echo can output multiple variable values, while print only has one variable, which is output as a string. Another difference is that echo does not return values. print has returned values. 1. print cannot output arrays and objects. Print_r can output stirng and in
Welcome to the Linux community forum, interact with 2 million technical staff> go to echo. The difference in print is that echo can output multiple variable values, while print has only one variable, which is output as a string. Another difference is that echo does not return values. print has returned values. 1. print cannot output arrays and objects. Print_r can output stirng and in
Welcome to the Linux community forum and interact with 2 million technicians>
The difference between echo and print is that echo can output multiple variable values, while print only has one variable and is output as a string. Another difference is that echo does not return values. print has returned values. 1. print cannot output arrays and objects.
Print_r can output stirng, int, float, array, object, etc. The structure is used to output the array, and true is returned when the print_r output is successful;
In addition, print_r can use print_r ($ str, true) to make print_r output and return the value after print_r processing.
It can be understood:
Print is a print string
Print_r prints composite types such as array objects.
In PHP, the execution speed is from fast to slow: echo (), print (), print_r ()
Echo is a PHP statement, print and print_r are functions, and the statement does not return values. The function can return values (even if it is not used)
Print () can only print values of simple type variables (such as int and string)
Print_r () can print values of complex types of variables (such as arrays and objects)
Echo outputs one or more strings
Echo -- output one or more strings
Descr resume ption
Void echo (string arg1 [, string…] ) // The returned value is null.
Echo "hello", "friend ";
Print -- output a string
Descr resume ption
Int print (string arg) // the return value is an integer.
Print "your good friend ";
You can perform the following operations:
$ Name = print "nihao/n ";
$ 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 [, bool return]) // the return value is Boolean and the parameter type is mix. It can be a string, an integer, an array, and an object class print_r () displays easy-to-understand information about a variable. If the value is string, integer, or float, the variable value is printed. If array is provided, keys and elements are displayed in a certain format. Objects are similar to arrays.
[1] [2]