print和echo的区别

来源:互联网 发布:百度搜索数据 编辑:程序博客网 时间:2024/05/18 13:10

/**************By Jiangong SUN******************/

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更快。

原创粉丝点击