This blog post has explored this question to a greater depth than you may have even known was possible.
Two differences:
print
has a return value, echo
doesn't. Therefore print
is slightly slower but may be used in function context.
echo
accepts multiple arguments. So you may write echo $a, $b
instead of echo $a . $b
. The former one will be faster, because the strings are echoed directly, without the necessity of first copying them to a new chunk of memory.
Concerning the parentheses: They are simply wrong in my eyes. They have no function at all. You could as well write echo (((((((((($a))))))))))
; it is simply stupidity and/or ignorance. Furthermore it increases the chance of misinterpretation. For example print("foo") && print("bar")
does not print foobar
, because PHP interprets this as print(("foo") && print("bar"))
. So bar1
would be printed, even though it looks different.