I'm making an API and in one of the endpoints the variable user_type that can only be a 0 or a 1
api/user?user_type=0 || api/user?user_type=1
Inside my controller i check if the variable equals to one of those two values, the problem is that the comprobation results in a boolean one, and if in the endpoint i add a text value for user_type results in true because the variable exists.
Is there any way of evaluating without triggering a boolean result? Something like this:
if($variable != 0 && $variable != 1){ return true } //It should be false if $variable == 'text' and true if variable == 0 or 1