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>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1953">
<img src="https://img.php.cn/upload/ai_manual/001/246/273/68b6d2021ce27238.png" alt="Friday AI">
</a>
<div class="aritcle_card_info">
<a href="/ai/1953">Friday AI</a>
<p>国内团队推出的智能AI写作工具</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="Friday AI">
<span>126</span>
</div>
</div>
<a href="/ai/1953" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="Friday AI">
</a>
</div>
<p><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p>
</volist></span>【推荐学习:PHP视频教程】
以上就是php隐藏手机号中间四位的方法的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号