Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6161439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:28:48+00:00 2026-05-23T21:28:48+00:00

I was browsing these PHP Coding Guidelines (a bit outdated but very interesting), and

  • 0

I was browsing these PHP Coding Guidelines (a bit outdated but very interesting), and found this:

Condition Format

Always put the constant on the left hand side of an
equality/inequality comparison. For example: if ( 6 == $errorNum ) …

One reason is that if you leave out one of the = signs, the parser
will find the error for you. A second reason is that it puts the value
you are looking for right up front where you can find it instead of
buried at the end of your expression. It takes a little time to get
used to this format, but then it really gets useful.

I have been using ($var == 6) for years now and the idea of putting them the other way around is horrifying. But as mentioned, this takes a bit time to get used to and is supposed to have clear benefits. We are just writing up standard at our company so if we want to change this, this is the moment to do that. But I’d like to hear if other have experience with this particular format. Any opinions?

EDIT

I am interested in people’s experience with making this switch. To me, and most likely to others, this looks like a big change that you need to get used to. But it looks interesting. So the question to those who have switched: can you recommend this change?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:28:49+00:00Added an answer on May 23, 2026 at 9:28 pm

    6 == $var has a real advantage that $var == 6 does not. There is nothing horrifying about it at all, it just looks different. You should get used to it and use it. In fact, I haven’t gotten used to it yet and I forget about it frequently. You really have to think about it and use it since the opposite is so common.

    The advantage, in case you didn’t know, is to prevent simple syntactical mistakes, thus:

    if ($var = 6) {} //weird semantic error
    if (6 = $var) {} //parse error
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was browsing the template.php file for the rootcandy theme and noticed some of
Browsing the Internet, I found the new Ample SDK JavaScript framework. From their about
From browsing on this site and elsewhere, I've learned that serving websites as XHTML
When browsing ASP.NET MVC source code in codeplex , I found it is common
Now I have my website built on PHP & Mysql. Consider this like a
This may be closed, a couple of minutes from now, but I think I
Very likely I'm going about this in the wrong way entirely. I'm completely new
I was browsing through Mirosoft training website and found that they offer quite a
Say Im reading a thread or browsing threads at read.php?tid=1 or category.php?cid=1 respectively And
I'm developing a web service. With this service, user's will upload their .php files,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.