The below code is working with only print statement
file_exists('index.php') || print "hi"; \\ works fine and prints hi
file_exists('index.php') || echo "hi"; \\ error
Why does print work but echo causes a parse error?
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.
This is because
echois a language construct andprintis a built-in function.Using
echois also slightly faster thanprintfor the same reason, but causes a parser error when used inside an expression.See also the bug report: https://bugs.php.net/bug.php?id=15866