Share
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.
echoandprintare virtually (not technically) the same thing. The (pretty much only) difference between the two is thatprintwill return the integer1, whereasechoreturns nothing. Keep in mind that neither is actually a function, but rather language constructs.echoallows you to pass multiple strings when using it as if it were a function (e.g.,echo($var1, $var2, $var3)).echocan also be shorthanded by using the syntax<?= $var1; ?>(in place of<?php echo $var1; ?>).As far as which is faster, there are many online resources that attempt to answer that question. PHP Benchmark concludes that “[i]n reality the echo and print functions serve the exact purpose and therefore in the backend the exact same code applies. The one small thing to notice is that when using a comma to separate items whilst using the echo function, items run slightly faster.”
It will really come down to your preference, since the differences in speed (whatever they actually are) are negligible.