时间:2021-07-01 10:21:17 帮助过:40人阅读
在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 $txt1;
print "
";
print "Study PHP at $txt2";
print "My car is a {$cars[0]}";
?>
好了,暂时就这些了,想起来再补,欢迎广大网友来喷!!!!!!
http://www.bkjia.com/PHPjc/1133564.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1133564.htmlTechArticleecho和print语句,echoprint语句 在php中,有两种基本的输出方法:echo 和 print echo 和 print 之间的差异: echo能够输出一个以上的字符串,无返回...