/**************by garcon1986******************/
print和echo的区别:
1. echo可以输入多个字符串,而print不能。
<?php
print "hello"."world"; //成功
echo "hello"."world"; //成功
print "hello","world"; //失败
echo "hello","world"; //成功
?>
2. echo比print更快。
<?php
$stime = microtime(true);
print "hello"."world";
$etime = microtime(true);
$total = $etime - $stime;
echo $total.'<br/>';
$stime2 = microtime(true);
echo "hello"."world";
$etime2 = microtime(true);
$total2 = $etime2 - $stime2;
echo $total2.'<br/>';
?>
执行结果:
helloworld0.0014331340789795
helloworld0.00018310546875
看到echo比print更快。
本文对比了PHP中print和echo两种输出方式的区别,指出echo可以输入多个字符串而print不可以,并通过实验证明了echo在执行速度上优于print。
2527

被折叠的 条评论
为什么被折叠?



