Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP if ( $some_var == 1 ) always returns true even if it's not true?

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?

like image 773
GeekedOut Avatar asked Nov 18 '11 20:11

GeekedOut


1 Answers

you need to use 3 equals

if($some_var ===1){

here is more info http://php.net/manual/en/language.operators.comparison.php

like image 113
Johnny Craig Avatar answered Nov 09 '22 06:11

Johnny Craig