Differences between echo, print_r and var_dump in PHP

Source: Internet
Author: User
This article mainly introduces the differences between echo, print_r, and var_dump in PHP. it mainly describes the nature of the three types and the usage differences of the operational data types, which is of great practical value, for more information about echo, print_r, and var_dump in PHP, see the following section. Share it with you for your reference. The specific analysis is as follows:

All three are php statements with output functions, but print_r (expression), var_dump (expression) is a function, and echo is only a language structure, not a function, so it cannot be part of the expression.

For the eight data types used to operate php:

Echo is used to output numeric variables or strings. However, when echo is used to output referenced variables, such as arrays, only the names of arrays are output.When an object is output, the server prompts Error. echo can only be used to output strings.

Print_r (expression) is used to output an array. In fact, the expression type of the parameter can be a numerical variable or a reference variable..

③ Var_dump (expression) function output result <Variable type, variable value, variable length> The expression parameter indicates various variable types. Output the details of a variable..

I hope this article will help you with PHP programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.