Basic PHP parsing (2) echo and print

Source: Internet
Author: User
In PHP, echo and print can both be used for output statements, but there are some usage differences between them. 1. In the official PHP manual, echo and print are not actually a function. They are a language structure and do not need to use parentheses to expand the parameter list behind print. Echo does not return, and print does. 2. echo can output strings,

In PHP, echo and print can both be used for output statements, but there are some usage differences between them. 1. In the official PHP manual, echo and print are not actually a function. They are a language structure and do not need to use parentheses to expand the parameter list behind print. Echo does not return, and print does. 2. echo can output strings,

In PHP, echo and print can both be used for output statements, but there are some usage differences between them.

1. In the official PHP manual, echo and print are not actually a function. They are a language structure and do not need to use parentheses to expand the parameter list behind print. Echo has no return value, and print has a return value.

2. echo can output strings separated by commas. Print can output only one string. That is to say, echo can receive different parameters, and print can only accept one parameter.

 "." My age is 20 "."
"," My college is in Beijing ","
"; Print" my hometown is in Beijing ";?>
Tip: (1) because echo does not return values at runtime, it is slightly more efficient than print, which is suitable for some relatively simple outputs.

(2) Because print has a return value, false is returned when the output fails, so it is suitable for some complicated expressions.

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.