A little talk about the Echo and print of PHP

Source: Internet
Author: User
Self-taught PHP for almost 2 months. Learn to do something, basic functions with the same, with the help point open plus search to find. Basically, no problem.
However, the description of the PHP homepage is very vague, a lot of parameters to say or do not understand, there is practice to the truth. There's nothing wrong with that.

The first is the difference between Echo and print, summed up the following:

Echo () and print () the difference between the small talk

Same as String output echo and Echo, what's the difference, Nikki?!!

PHP said, in fact, which is not very strict. They can all work without brackets ().
At present, only 3 points are found to be relatively large differences.

1. Echo () can be separated by a comma, the number of strings, print () can not

Print "Hello", "World"; Syntax error.
echo "Hello", "World"; Syntax ok!!

※echo () After the parentheses "()", add a comma, or distinguish the number of strings also not! Please note that.

2. Print () returns, Echo () does not return.

1 $output 1 = print "Hello world"; This one with the output.
2 $output 2 = echo "Hello World"; This one's not there!

3. If you do not need to return the result operation, Echo () is slightly 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 judge the difference?

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