小编cre*_*hea的帖子

preg_match模式在php v 5中不起作用

我正在使用PHP版本5.4.45.我在php版本7中测试此代码并且工作正常但在5.4.45版本中无效

$string = '9301234567';
if( preg_match('/^\9\d{9}/', $string) ) 
{
    $string = '0+1'.$string ;
    return $string ;
}
Run Code Online (Sandbox Code Playgroud)

在v7返回:

0+19301234567
Run Code Online (Sandbox Code Playgroud)

但是在v5.4.45中返回(preg_match返回false)

9301234567
Run Code Online (Sandbox Code Playgroud)

我怎么能preg_match('/^\9\d{9}/', $string) 在php v5.4.45中使用?谢谢

php regex preg-match

3
推荐指数
1
解决办法
101
查看次数

标签 统计

php ×1

preg-match ×1

regex ×1