Difference: 1. Both the echo() and print() functions are used to output one or more strings, but echo has no return value and is slightly faster than print; 2. The "print_r()" function is used Used to display easy-to-understand information about variables; 3. "var_dump" is used to display structural information of one or more expressions.
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
echo In-depth understanding of echo, echo is a function
echo function: output one or more strings to the browser;
echo return value: void No return value;
echo "今天是个好天气";
Output result:
##print function: output string to the browserprint return value: integer 1The following example: print prints out the string, and echo prints out the return value of printecho(print("今天是个好天气"));
$a = [1,2,3,4,]; print_r($a);
##var_dump() displays structural information about one or more expressions , including the type and value of the expression. Arrays will expand values recursively, showing their structure through indentation.
For example:
$b = array( 1 , 2 , array( "a" , "b" , "c" )); var_dump ( $b );
Output result:
For example:
$d = 3.1 ; $c = true ; var_dump ( $d , $c );
Output result:
Recommended learning: "
PHP Video TutorialThe above is the detailed content of What is the difference between php output statements. For more information, please follow other related articles on the PHP Chinese website!