标签:
在 PHP 中,有两种基本的输出方法:echo 和 print
echo 和 print 之间的差异:
提示:echo 比 print 稍快,因为它不返回任何值。
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."; ?>
<?php $txt1="Learn PHP"; $txt2="W3School.com.cn"; $cars=array("Volvo","BMW","SAAB"); echo $txt1; echo "<br>"; echo "Study PHP at $txt2"; echo "My car is a {$cars[0]}"; ?>
print 也是语言结构,有无括号均可使用:print 或 print()。
<?php print "<h2>PHP is fun!</h2>"; print "Hello world!<br>"; print "I‘m about to learn PHP!"; ?>
<?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]}";
?>
标签:
原文地址:http://www.cnblogs.com/rae-sai/p/5500519.html