php隐藏手机号中间四位的方法:1、通过“substr_replace($num,'****',3,4);”方法隐藏手机号中间四位;2、通过自定义“yc_phone”函数隐藏中间四位即可。
本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑
php方法 隐藏手机号中间四位$num = "13966778888"
$str = substr_replace($num,'****',3,4);//自定义函数手机号隐藏中间四位
function yc_phone($str){
$str=$str;
$resstr=substr_replace($str,'****',3,4);
return $resstr;
}
在thinkphp模板里的用法:
恭喜用户{$vo.user_id|yc_phone=###}砸金蛋获得奖金{$vo.prize}元
【推荐学习:PHP视频教程】