"PHP Learning" PHP 5 echo and Print statements

Source: Internet
Author: User
Tags echo command learn php php print

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

In this tutorial, we'll use echo and print in almost every example. Therefore, this section provides you with more knowledge about these two output statements. 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

The following example shows how to display different strings with the echo command (also note that the string can contain HTML tags):

<? PHP Echo "; Echo "Hello world!<br>"; Echo "I ' m about to learn Php!<br>"; Echo "This", "string", "is", "made", "with multiple parameters." ;? >

Run instance display variable

The following example shows how to use the echo command to display strings and variables:

<? PHP $txt 1= "Learn PHP"; $txt 2= "W3School.com.cn"; $cars=array("Volvo", "BMW", "SAAB"); Echo $txt 1 ; Echo "<br>"; Echo $txt 2"; Echo "My car is a {$cars[0]}";? >

Running the instance PHP print statement

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

The following example shows how to use the Print command to display different strings (also note that the string can contain HTML tags):

<? PHP Print "; Print "Hello world!<br>"; Print "I ' m about to learn php!" ;? >

Run instance display variable

The following example shows how to use the Print command to display strings and variables:

<? PHP $txt 1= "Learn PHP"; $txt 2= "W3School.com.cn"; $cars=array("Volvo", "BMW", "SAAB"); Print $txt 1 ; Print "<br>"; Print $txt 2"; Print "My car is a {$cars[0]}";? >
Running an instance

"PHP Learning" PHP 5 echo and Print statements

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.