Checking “$phone”


"; // remove spaces $phone = str_replace(" ", "", $phone); // remove dashes $phone = str_replace("-", "", $phone); // remove ( $phone = str_replace("(", "", $phone); // remove ) $phone = str_replace(")", "", $phone); //debug: echo strlen($phone); // Check for 7 or 10 characters long if (strlen($phone) !== 7 && strlen($phone) !== 10) { ++$failures; echo "

Warning: “$phone” must be 7 or 10 characters

"; //if ((strlen($phone) !== 7) || (strlen($phone) !== 10)) } // Check for numbers if (!is_numeric($phone)) { ++$failures; echo "

Warning: “$phone” contains non numeric characters

"; } if ($failures == 0) echo "

“$phone” is valid

"; else echo "

“$phone” is not valid

"; } ?>