MrHellism Posted February 18, 2015 Share Posted February 18, 2015 Hey friends, I just started learning php. I want to know the difference between == and === I exactly want to know the comment section of the given code below. Thanks. <?php$mystring = 'abc';$findme = 'a';$pos = strpos($mystring, $findme);// The !== operator can also be used. Using != would not work as expected// because the position of 'a' is 0. The statement (0 != false) evaluates // to false.if ($pos !== false) { echo "The string '$findme' was found in the string '$mystring'"; echo " and exists at position $pos";} else { echo "The string '$findme' was not found in the string '$mystring'";}?> Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted February 18, 2015 Share Posted February 18, 2015 Perhaps the following will help: http://php.net/manual/en/language.operators.comparison.php Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted February 18, 2015 Share Posted February 18, 2015 Also, in case it helps, the documentation for strpos() explains why you need to use the === or !== operator. http://php.net/manual/en/function.strpos.php See the pink Warning box in the Return Values section. Quote Link to comment Share on other sites More sharing options...
MrHellism Posted February 18, 2015 Author Share Posted February 18, 2015 Thanks a lot 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.