Just curious…when writing a require/include statement, what do you prefer as better practice?
require('filename.php');
or
require 'filename.php';
Thanks!
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.
Always the latter – the same applies to
echo,printand other language constructs, too. Never add additional parenthesis after language constructs!The reason is simple: Using parenthesis makes you believe that
requireis a function – which it is not! For example:You – and probably even most of the senior PHP developers – would say that this compares the return value of the
require. But it does not! PHP interprets this as:which is:
If you use parenthesis with language constructs you could as well write:
Or would you ever write:
That’s just as much the same nonsense.