I know the performence difference will be very slight in both scenarios, but I was wondering which is a more practical, performance-improving version to write conditions in PHP.
if(condition){
result;
}
VS
if(condition)
result;
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.
Both are exactly the same, it’s coding style and has nothing to do with performance. Adapt the style you like better.
Some hint tools suggest to use the first style to avoid mistakes like this:
While if you were using curly braces, this wouldn’t have happen:
I’m not using curly braces by the way for one statement in
if, as this scenario isn’t too difficult to avoid for non noobs.