Hello,everyone.🙂
I am writing a code for validating whether the user has input a valid mobile phone number.It goes like this:
$num='a61752424';
for($i=0;$i<strlen($num);$i++)
{
$match=false;
$str=substr($num,$i,1);
for($a=0;$a<=9;$a++)
{
if($str==$a)
{
$match=true;
}
}
if(!$match)
break;
}
if(!$match)
echo "Input invalid.";
else
echo "Input valid.";
However,what surprise me is that,it turned out to be input valid!Why does the string a equal to 0?I don't know at all.
Please give me some clue on that.😉