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模板里的用法:
<span style="font-size:18px;"><volist name="zjd_list" id="vo">
<p>恭喜用户{$vo.user_id|yc_phone=###}砸金蛋获得奖金{$vo.prize}元</p>
</volist></span>【推荐学习:PHP视频教程】
立即学习“PHP免费学习笔记(深入)”;
以上就是php隐藏手机号中间四位的方法的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号