在 PHP 中,有兩種基本的輸出方法:echo 和 printphp
echo 和 print 之間的差別:ip
提示:echo 比 print 稍快,由於它不返回任何值。字符串
echo 是一個語言結構,有無括號都可使用:echo 或 echo()。string
<?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()。it
<?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]}";?>