function sendSms($toPhone,$message){
$toPhone=intval(trim($toPhone));
if(strlen($toPhone)== 8 && $toPhone{0}==9){
//sending sms
}else{
return "error";
}
}
I am trying to validate mobile numbers for sending SMS. The first line trims the phone number string and then converts it to an integer. In the if
statement, I want to make sure that the number length is 8 digits and it begins with 9. This function always goes for the else
even if the number is correct( 8 digits and begins with 9). What could be the issue here.