This article已经探讨过这个问题,以更大的深度比你甚至可能已经知道是可能的。
来自:http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40
1.
Speed. There is a difference between the two, but speed-wise it should be irrelevant which one you use. echo is marginally faster since it doesn't set a return value if you really want to get down to the nitty gritty.
2.
Expression. print() behaves like a function in that you can do: $ret = print "Hello World"; And $ret will be 1. That means that print can be used as part of a more complex expression where echo cannot. An example from the PHP Manual:
$b ? print "true" : print "false";
打印也是其它需要的,如果它是要内的使用的优先顺序表的一部分复杂的表达。它只是在优先级列表的底部。只有“,”AND,OR和XOR较低。
- 参数(一个或多个)。语法是:echo expression [,expression [,expression] ...]但是echo(expression,expression)无效。这将是有效的:echo(“howdy”),(“partner”);相同:echo“howdy”,“伙伴”; (把括号放在这个简单的例子中是没有用的,因为没有像这样的单个术语的运算符优先级问题。)
因此,回声不带括号可以采取多种参数,其中获得级联:
echo "and a ", 1, 2, 3; // comma-separated without parentheses
echo ("and a 123"); // just one parameter with parentheses
打印()只能取一个参数:
print ("and a 123");
print "and a 123";
因为`echo`没有返回值 – Mchl 2011-01-14 18:32:40