PHP之echo/print

1.PHP中有两个基本的输出方式:echo和print;

2.echo和print的区别:

**echo:可以输出一个或多个字符串;

**print:只允许输出一个字符串,返回值总为1;

 

3.echo是一个语言结构,使用的时候可以不用加括号,也可以加上括号:echo或echo()

<?php

echo "<h2>PHP is fun!</h2>";

echo "Hello world!<br>";

echo "I'm about to learn PHP!<br>";

echo "This"," string","was","made","with multiple parameters.";

?>

 

4.echo命令输出变量和字符串:

<?php

$txt1="Learn PHP";

$txt2="w3cshool.cc";

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

echo $txt1;

echo "<br>";

echo "Study PHP at $txt2";

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

?>

 

5.PHP的print语句:print同样是一个语言结构,可以使用括号,也可以不使用括号:print或print();

<?php

print "<h2>PHP is fun!</h2>";

print "Hello world!<br>";

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

?>

 

posted @ 2016-11-16 09:39  小春熙子  阅读(197)  评论(0编辑  收藏  举报