Echo and Print statements, echoprint statements _php Tutorial

Source: Internet
Author: User
Tags learn php

Echo and Print statements, echoprint statements


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

The difference between Echo and print:

    • echo--can output more than one string, no return value
    • print--can only output one string, and always return a value of 1

Echo's statement:

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

For example:

Display string:

echo "

PHP is fun!

";

echo "Hello world!";

echo "Plan", "Learn", "PHP";

?>

Display variables:

$txt 1 = "Learn PHP";

$txt 2 = "***.com";

$cars = Array ("Volvo", "BWM", "AABB");

echo $txt 1;

echo "
";

echo "Study PHP at $txt 2";

echo "
";

echo "My car is a {$cars [0]}";

?>

Print's statement:

Print is also a language structure and can be used without brackets: print or print ();

Display string:

Print "

PHP is fun!

";

Print "" Hello world!
";

Print "I ' m about to learn php!";

?>

Display variables:

$txt 1= "Learn PHP";

$txt 2= "W3School.com.cn";

$cars =array ("Volvo", "BMW", "SAAB");

Print $txt 1;

Print "
";

Print "Study PHP at $txt 2";

Print "My car is a {$cars [0]}";

?>

Well, temporarily on these, think up again, welcome the vast number of netizens to spray!!!!!!

http://www.bkjia.com/PHPjc/1133564.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133564.html techarticle Echo and Print statements, echoprint statements in PHP, there are two basic output methods: Echo and print echo and print differences: echo can output more than one string, no return ...

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