PHP Echo and Print

Source: Internet
Author: User
Tags learn php php print

In PHP, there are two basic output methods: Echo and Print

PHP Echo and Print statements

The difference between Echo and print:

    • echo-capable of outputting more than one string
    • Print-only one string is output and always returns 1

Tip: Echo is slightly faster than print because it does not return any values.

PHP Echo Statement

Echo is a language structure that can be used with or without parentheses: Echo or Echo ().

Display string
<?phpecho "
Show variables
<?php$txt1= "Learn PHP"; $txt 2= "W3School.com.cn"; $cars =array ("Volvo", "BMW", "SAAB"), Echo $txt 1;echo "<br>"; echo "Study PHP at $txt 2", echo "My car is a {$cars [0]}";? >
PHP Print Statement

Print is also a language structure and can be used with or without parentheses: print or print ().

Display string
<?phpprint "
Show variables
<?php$txt1= "Learn PHP"; $txt 2= "W3School.com.cn"; $cars =array ("Volvo", "BMW", "SAAB");p rint $txt 1;print "<br> ";p rint" Study PHP at $txt 2 ";p rint" My car is a {$cars [0]} ";
?>

PHP Echo and Print

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.