why ereg("^\d{11}$",18311111111) is false?
ereg, php, regex
Solution
Because `ereg` does not support `\d`, you need use `[0-9]` instead.
And `ereg` is deprecated, use `preg_match` instead, then you could use `\d`.
if(preg_match("/^\d{11}$/",$phone)){
echo "true";
} else {
echo "false";
}
Problem
my code is: ``` <?php $phone = 18311111111; if(ereg("^\d{11}$",$phone)){ echo "true"; } else { echo "false"; } ?> ``` i get false? why?