PHP - if == not working for 0 or ""
- by user2933212
I am checking the validation of the request with an if query,
if ($request_userid == $userid) {
...
}
Thats working as expected. But further testing has shown, that if $request_userid or $userid is 0 or "", then the condition is true and the script runs the if query but it shouldn't.
I am currently solving it with:
if ($userid == "" ) {
exit ("exit");
}
But I don't think that this is the right way?
Can you explain why it doesn’t work with the if query and what would be the correct way to check it?