Echo and print statements, echoprint statements

Source: Internet
Author: User

Echo and print statements, echoprint statements

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:

<? Php

Echo "

Echo "Hello world! ";

Echo "plan", "Learning", "PHP ";

?>

Display variables:

<? Php

$ Txt1 = "Learn PHP ";

$ Txt2 = "***. com ";

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

 

Echo $ txt1;

Echo "<br> ";

Echo "Study PHP at $ txt2 ";

Echo "<br> ";

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:

<? Php

Print "

Print "" Hello world! <Br> ";

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

?>

Display variables:

<? Php

$ Txt1 = "Learn PHP ";

$ Txt2 = "W3School.com.cn ";

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

Print $ txt1;

Print "<br> ";

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 !!!!!!

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.