What is the difference between the Echo statement and the print statement in PHP5

Source: Internet
Author: User
Tags echo command learn php
This article introduces to you about the PHP5 in the Echo statement and print statements are different, there is a certain reference value, the need for friends can refer to, I hope to help you.

PHP Echo and Print statements

Echo and Print differences:

    • echo-Can output one or more strings, no return value

    • Print- allows only one string to be output, with a Total return value of 1

tip:echo outputs faster than print , ECHO has no return value, and print has a return value of 1.

PHP Echo Statement

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

Display string

The following example shows how to use the echo command to output a string (the string can contain HTML tags):

<?phpecho "

How to output variables and strings

<?php$txt1= "Learning php", $txt 2= "Liuhang", $cars =array ("Volvo", "BMW", "Toyota"); echo $txt 1;echo "<br>", echo "$txt 2 love to learn PHP", echo "<br>", echo "the brand of my car is {$cars [0]}";? >

Print statement

In addition to outputting only one string at a time, it is no different from Echo.

<?php$txt1= "Learning php", $txt 2= "Liuhang", $cars =array ("Volvo", "BMW", "Toyota"); Print $txt 1;print "<br>;p rint" $txt 2 love to learn PHP ";p rint" <br> ";p rint" My car brand is {$cars [0]} ";? >

Related articles recommended:

Example code for _get methods and _set method access methods in PHP

The use of the Echo () function in PHP (with code)

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.