在php中,有兩種基本的輸出方法:echo 和 print
echo 和print 之間的差異:
echo的語句:
echo是一個語言結構,有無括號皆可使用:echo 或echo();
例如:
顯示字串:
php
echo "
echo "Hello world!";
echo "計畫","學習","PHP";
?>
顯示變數:
$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的語句:
print也是語言結構,有無括號皆可使用: print 或print();
顯示字串:
print "
print ""Hello world!
";
print "I'm about to learn PHP!";
?>
顯示變數:
$txt1="Learn PHP";
$txt2="W3School.com.cn";
$cars=array("Volvo","BMW","SAAB");
print $11 ;print "
";print "Study PHP at $txt2"; print "My car is a {$cars[0]}";
?>好了,暫時就這些了,想起來再補,歡迎廣大網友來噴! ! ! ! ! ! 以上就介紹了unable to print echo和print語句,包含了unable to print方面的內容,希望對PHP教學有興趣的朋友有幫助。