brentmoeller Posted March 8, 2011 Share Posted March 8, 2011 $a === $b if $a is equal to $b, and of the same type when would you ever need to use this operator? I mean if its not == then its going to be false so why even test if its the same type. and if it is == then in theory it has to be the same type so why test it? Am i completely over looking something? Quote Link to comment Share on other sites More sharing options...
dk4210 Posted March 8, 2011 Share Posted March 8, 2011 Hi Brent, The difference is that == will return TRUE whether the two operands have the same value or not. === evaluates to TRUE if the two operands have the same value and are the same type. 99% of the time I just use == . I've never used === Quote Link to comment Share on other sites More sharing options...
mikecampbell Posted March 8, 2011 Share Posted March 8, 2011 When PHP tests variables of different types with ==, it converts them to be compatible. If you compare (0 == false), it evaluates to true. Same if you compare ("" == false). However, (0===false) and (""===false) both evaluate to false. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 8, 2011 Share Posted March 8, 2011 It's indispensable for use with a function that can return either an integer or a boolean true/false. See the manual entry for strpos(), for example. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.