PHP 5 related knowledge and application of ECHO and print statements

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

There are two basic output modes in PHP: Echo and print. In this article, we'll discuss the use of both statements in detail, and demonstrate in the example how Echo and print are used.

PHP Echo and Print statements

Echo and Print differences:

echo-can output one or more strings

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

Tip: The echo output is 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):

Instance

<?phpecho "


Try it»

Show variables

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

Instance

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

PHP Print Statement

Print is also a language structure, you can use parentheses, or you can use no parentheses: Print or print ().

Display string

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

Instance

<?phpprint "

Show variables

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

Instance

<?php$txt1= "Learning php", $txt 2= "runoob.com", $cars =array ("Volvo", "BMW", "Toyota"); Print $txt 1;print "<br>";p rint "in $txt 2 to learn PHP";p rint "<br>";p rint "the brand of my car is {$cars [0]}";? >

This article on the PHP 5 echo and Print statements related knowledge and use to make some explanations, more learning materials to clear concern about the PHP Chinese network can be viewed.

Related Article

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.