View Single Post
Old 06-01-2014, 03:06 PM  
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,620
Quote:
Originally Posted by edgeprod View Post
Just be careful with this .. a lot of people here have a "sort of" understanding of PHP. If you use the exact match syntax with other variable types, PHP acts in unexpected ways. For example, even though PHP has a very forgiving manner of variable typing (string versus float, etc) when compared to C or Java, it acts strictly when using ===.

$variable = '5';
if ($variable === 5) will react differently than if ($variable == 5) or if ($variable === '5')

(false, true, true)
Correct, quoted 5 is not type integer; the variable type must match for exact match.
And that pretty much sums up what the thread is about.
Doing the correct test on the returned value, which this time requires type.
blackmonsters is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote