Home >Backend Development >PHP Tutorial >echo and print statements, echoprint statement_PHP tutorial

echo and print statements, echoprint statement_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-12 08:50:221067browse

echo and print statements, echoprint statement

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

Difference between echo and print:

  • echo - can output more than one string, no return value
  • print - can only output a string and always returns a value of 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","Learn","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 now. I’ll add more when I think of it. Netizens are welcome to comment! ! ! ! ! !

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1133564.htmlTechArticleecho and print statements, echoprint statements In php, there are two basic output methods: echo and print echo and The difference between print: echo can output more than one string, without returning...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn