Echo and print statements, echoprint statement _ PHP Tutorial

Source: Internet
Author: User
Echo and print statements, and echoprint statements. Echo and print statements, echoprint statements in php, there are two basic output methods: echo and printecho and print differences: echo can output more than one string, no echo or print statements are returned.

In php, there are two basic output methods: echo and print

Differences between echo and print:

  • Echo -- can output more than one string without returning a value
  • Print -- only one string can be output, and the return value is always 1

Echo statement:

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

For example:

Display string:

Echo "PHP is fun! ";

Echo "Hello world! ";

Echo "plan", "learning", "PHP ";

?>

Display variables:

$ Txt1 = "Learn PHP ";

$ Txt2 = "***. com ";

$ Cars = array ("Volvo", "BWM", "AABB ");

Echo $ txt1;

Echo"
";

Echo "Study PHP at $ txt2 ";

Echo"
";

Echo "my car is a {$ cars [0]}";

?>

Print statement:

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

Display string:

Print "PHP is fun! ";

Print "" Hello world!
";

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

?>

Display variables:

$ Txt1 = "Learn PHP ";

$ Txt2 = "W3School.com.cn ";

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

Print $ txt1;

Print"
";

Print "Study PHP at $ txt2 ";

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

?>

Okay. that's all for the time being. let's try again. You are welcome to join us !!!!!!

Callback has two basic output methods in php: the difference between echo and print: echo can output more than one string without returning...

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.