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