Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do we use == rather than ===
#2
(10-11-2010, 06:39 AM)Orgy Wrote: If "===" means "exactly equal", then why don't we use it all the time. Well, with the exception of checking if something is true (true, >0, etc)

But I rarely see anyone ever use "===" for comparing strings. Why not? Wouldn't that be more accurate?

It's more accurate if you need it to be. Most people utilize PHP's ability to blur data types. You can compare "4" and 4 and they'd be equal. This is useful in certain situations but dangerous in others because people get complacent. If you know what you're comparing will always be a string and it always needs to be a string, then use the identical operator (===).
Ho, ho, ho! Well, if it isn't fat stinking billy goat Billy Boy in poison!
How art thou, thou globby bottle of cheap, stinking chip oil?
Come and get one in the yarbles, if ya have any yarbles, you eunuch jelly thou!
Reply


Messages In This Thread
Why do we use == rather than === - by Orgy - 10-11-2010, 06:39 AM
RE: Why do we use == rather than === - by Disease - 10-11-2010, 06:42 AM
RE: Why do we use == rather than === - by Disease - 10-11-2010, 09:12 AM
RE: Why do we use == rather than === - by Orgy - 10-11-2010, 09:27 AM
RE: Why do we use == rather than === - by Orgy - 10-11-2010, 06:45 AM
RE: Why do we use == rather than === - by Orgy - 10-11-2010, 06:57 AM
RE: Why do we use == rather than === - by Chimi - 12-06-2010, 01:29 AM
RE: Why do we use == rather than === - by Orgy - 12-09-2010, 06:23 AM

Forum Jump:


Users browsing this thread: 7 Guest(s)