PHP echo and print tips

Source: Internet
Author: User
Document directory
  • Differences between echo () and print ()

Php has been self-taught 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 ()

Same as string outputEcho and echoWhat is the difference ?!!

In the PHP statement, none of them are very strict.They do not need arc.() And work normally.
At present, we only find the big difference between three points.

1.echo()You can use commas (,) to separate the number of shards,Print () is not allowed Print "Hello", "World"; // syntax error.
Echo "Hello", "World"; // syntax OK !!

echo()After using the arc "()", add the comma "," to distinguish between the string numbers! Note.

2.print()Return result,echo()But does not return. 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 a little faster.

 

Echo () vs print ()

Echoing 100000 of nothing
Exe Time is 0.034925937652588 secs.

Printing 100000 of nothing
Exe Time is 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.