代码如下 | 复制代码 |
//验证手机号 $match = '/^((13[0-9])|(15[^4,\d])|(18[0,5-9]))[0-9]{8}$/'; //验证座机 $match = '/^(0[0-9]{2,3}-)?([2-9][0-9]{6,7})+(-[0-9]{1,4})?$/'; //验证身份证号15或18位 $match = '/(^d{15}$)|(^d{17}(d|X|x)$)/'; //Email验证 $match = '/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/'; //将手机号中间转换为 * 号 $tel = 18600000000; $pattern = '/(d{3})d{4}(d{3})/'; $replacement = "$1****$2"; echo preg_replace($pattern,$replacement,$tel); |
时间: 2024-10-21 15:48:13