Jump to content

[SOLVED] Help understanding === vs. ==


nloding

Recommended Posts

I'm a little confused.  I see this more and more often when I look at open-source apps:

 

if(''===$var)

 

In every article, every book, that I have ever read (not that I've read nearly everything or that everything I've read was good), it's always been this:

 

if($var=='')

 

What's the difference between '===' and '==', and why put the value first instead of the variable?  Is there a performance or accuracy difference?  Is '===' case-sensitive?  How can it be more strict than '=='?  I Googled it, but some of the things I read made me more confused ...

Link to comment
https://forums.phpfreaks.com/topic/123829-solved-help-understanding-vs/
Share on other sites

If you look at it logically , you are saying

 

if variable one doesnt equal empty , then do

if($var != '')

 

or

 

if empty doesnt equal variable one , then do

if('' != $var)

 

Yeah, but logically, to me, those end up with the same result.  Either they are equal or they aren't.  2 * 3 = 6, and 6 = 3 * 2.  I was just curious if there was performance difference or something, but it sounds like I'll have to bench it to find out.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.