This issue is simple, but I am not sure what is the best approach to get around it.
If the variable contains a number, how can I make sure that the if statement only returns true if indeed the $some_var is one?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
PHP is a loosely typed language which means values can change their type depends on the context. When a loose comparison is used, 1 is treated equal to true, as well as any non-empty string.
you need to use 3 equals if you want to compare taking into account the variable type.
here is more info http://php.net/manual/en/language.operators.comparison.php