PHP echo and print tips

Source: Internet
Author: User
PHP echo and print have been learning php for more than two months. Learn how to do something, use basic functions, and use help to open and search. No problem
However, the descriptions on the php homepage are very vague. after many parameters are completed, they still cannot be understood, and the truth can be found only in practice. There is nothing wrong with this.

The difference between echo and print was first met. I have summarized the following:

Differences between echo () and print ()

What is the difference between string output echo and echo ?!!

PHP? Actually, none of them are strict. They can all work normally without arc.
At present, we only find the big difference between three points.

1. can echo () be separated by commas? Number of strings, print () is not allowed

Print "Hello", "World"; // syntax error.
Echo "Hello", "World"; // syntax OK !!

※After the Arc "()" is used for echo (), add a comma "," to distinguish? No number of strings! Note.

2. print () returns? If yes, echo () is not returned.

1 $ output1 = print "Hello World"; // This output has
2 $ output2 = echo "Hello World"; // This does not exist.

3. if you do not need to return results, echo () is faster.

Echo () vs print ()

Echoing 100000 of nothing
Exe Time is 0.034925937652588 secs.

Printing 100000 of nothing
Exe Time I s 0.037981986999512 secs.

Do you need to determine this gap?

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.