Here, $username
is a userinput, and I am trying to check if the entry was a username, or a userid (all integers)
I thought to use the intval function to see if $username
and intval($username)
is same, which means the input is a userid.
The input I gave was google
. and intval('google')
is 0. Why does the true part of the if statement get executed? Any idea?
I amnt using ===
because the userinput will be a string.
if($username == intval($username))
{
echo "userid";
}
else
{
echo "username";
}
Not sure why the unexpected behaviour is happening.