terryds Posted September 8, 2013 Share Posted September 8, 2013 Do you know the difference between double and triple equation ? I'm so confused... I often see triple equations in some functions ( like if (md5($a)===1) ) and others.... Link to comment Share on other sites More sharing options...
niche Posted September 8, 2013 Share Posted September 8, 2013 They're comparison operators http://www.w3schools.com/php/php_operators.asp Link to comment Share on other sites More sharing options...
astralaaron Posted September 8, 2013 Share Posted September 8, 2013 http://www.w3schools.com/php/showphp.asp?filename=demo_operator_comparison Link to comment Share on other sites More sharing options...
thescientist Posted September 9, 2013 Share Posted September 9, 2013 (edited) == will not do type casting, so 2 == "2" would be true. === will check for type, so 2 === "2" would be false. It is always best practice, IMO, to use ===, to make sure both the value and type of both sides are actually the same. Edited September 9, 2013 by thescientist Link to comment Share on other sites More sharing options...
Ingolme Posted September 10, 2013 Share Posted September 10, 2013 == will not do type casting, so 2 == "2" would be true. === will check for type, so 2 === "2" would be false. It is always best practice, IMO, to use ===, to make sure both the value and type of both sides are actually the same. Personally, I don't use === unless the type is strictly important in the comparison (functions that can return both 0 and false with different meanings). Using == can simplify things, like not having to type cast a variable before comparing it. You know all $_POST, $_GET and $_COOKIE values are strings, so when you want to compare them to a number it's simpler to use == than to cast them. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now