What is the preferred way to write this if statement, and why?

It is for static page, dynamic page, website, SEO, performance and other web development discussion
ramverma
Posts: 435
Joined: Sat Aug 23, 2014 5:34 pm
Contact:

What is the preferred way to write this if statement, and why?

Postby ramverma » Mon Oct 19, 2015 6:13 am

What is the preferred way to write this if statement, and why?
if( 5 == $someVar ) or if( $someVar == 5 )


jeff2345
Posts: 49
Joined: Tue May 05, 2015 7:09 pm
Contact:

Re: What is the preferred way to write this if statement, and why?

Postby jeff2345 » Tue Oct 20, 2015 6:46 am

The first one reduces the change to accidentally set the variable, while the other one potentially reduces needs context while reading the code.


Return to “PHP, HTML, MYSQL and Web Hosting”

Who is online

Users browsing this forum: No registered users and 0 guests