you can use this function with strlen to check illegal characters, string lenght must be the same than strspn (characters from my string contained in another)
<?php
$digits='0123456789';
if (strlen($phone) != strspn($phone,$digits))
echo "illegal characters";
?>