This article mainly introduces the analysis of the differences between echo, print_r and var_dump in PHP. It mainly talks about the type nature of the three and the usage differences of operating data types. It is of great practical value. Friends in need can refer to it
This article analyzes the differences between echo, print_r and var_dump in PHP in more detail. Share it with everyone for your reference. The specific analysis is as follows:
All three are PHP statements with output functions, but print_r(expression) and var_dump(expression) are functions, and echo is just a language structure, not a function, so it cannot be used as part of the expression.
For operating the 8 data types of php:
① echo is used to output numerical variables or strings. But when using echo to output reference variables, such as arrays, only the name of the array is output; when outputting an object, the server prompts <
Catchable fatal error: Object of class Person could not be converted
to string>error, the error shows that echo can only be used to output strings.
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
② The function of print_r(expression) is to output an array. In fact, the type of parameter expression can be numeric variables and reference variables.
③ The output result of the var_dump(expression) function is. The parameter expression represents various variable types, and its function is to output detailed information of a variable.
I hope this article will be helpful to everyone’s PHP programmingThe above has introduced the analysis of the differences between echo, print_r and var_dump in PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.