Home > Backend Development > PHP Tutorial > Analysis of the differences between echo, print_r and var_dump in PHP

Analysis of the differences between echo, print_r and var_dump in PHP

WBOY
Release: 2016-07-28 08:29:14
Original
1023 people have browsed it

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.
② 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 programming

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The 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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template