Possible Duplicate:
Reference: Comparing PHP's print and echo
Is there any major and fundamental difference between these two functions in PHP?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From: http://web.archive.org/web/20090221144611/http://faqts.com/knowledge_base/view.phtml/aid/1/fid/40
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.
Expression.
print()behaves like a function in that you can do:$ret = print 'Hello World'; And$retwill be1. That means that print can be used as part of a more complex expression where echo cannot. An example from the PHP Manual:print is also part of the precedence table which it needs to be if it is to be used within a complex expression. It is just about at the bottom of the precedence list though. Only
,ANDORXORare lower.echo expression [, expression[, expression] ... ]Butecho ( expression, expression )is not valid. This would be valid:echo ('howdy'),('partner'); the same as:echo 'howdy','partner'; (Putting the brackets in that simple example serves no purpose since there is no operator precedence issue with a single term like that.)So, echo without parentheses can take multiple parameters, which get concatenated:
print()can only take one parameter: