如何用PHP技术巧妙隐藏手机号码中间四位?

2026-04-06 09:320阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计513个文字,预计阅读时间需要3分钟。

如何用PHP技术巧妙隐藏手机号码中间四位?

推荐:PHP视频教程今天突然想起手机号,这种隐私信息在项目中还是隐藏一下比较好,以下是一些可用方法,仅限于大陆11位手机号:

1.使用 substr_replace 函数

substr_replace($phone, '**', 3, 4); // 将手机号第4位到第7位替换为**

推荐:《PHP视频教程》

今天突然想起手机号,这种隐私信息在项目中还是隐藏一下比较好,所以就来总结一下能用的方法,仅限于大陆的11位手机号

方法演示

1.使用 substr_replace函数

# substr_replace — 替换字符串的子串 # 使用说明 substr_replace ( mixed $string , mixed $replacement , mixed $start , mixed $length = ? ) : mixed # $string 资源字符串 # $replacement 替换字符 # $start 替换开始位置,如果位负数的时候,将从末尾开始数 # $length 需要替换的长度,如果为负数的时候,也是从$start开始位置替换 # substr_replace() 在字符串 string 的副本中将由 start 和可选的 length 参数限定的子字符串使用 replacement 进行替换。

阅读全文

本文共计513个文字,预计阅读时间需要3分钟。

如何用PHP技术巧妙隐藏手机号码中间四位?

推荐:PHP视频教程今天突然想起手机号,这种隐私信息在项目中还是隐藏一下比较好,以下是一些可用方法,仅限于大陆11位手机号:

1.使用 substr_replace 函数

substr_replace($phone, '**', 3, 4); // 将手机号第4位到第7位替换为**

推荐:《PHP视频教程》

今天突然想起手机号,这种隐私信息在项目中还是隐藏一下比较好,所以就来总结一下能用的方法,仅限于大陆的11位手机号

方法演示

1.使用 substr_replace函数

# substr_replace — 替换字符串的子串 # 使用说明 substr_replace ( mixed $string , mixed $replacement , mixed $start , mixed $length = ? ) : mixed # $string 资源字符串 # $replacement 替换字符 # $start 替换开始位置,如果位负数的时候,将从末尾开始数 # $length 需要替换的长度,如果为负数的时候,也是从$start开始位置替换 # substr_replace() 在字符串 string 的副本中将由 start 和可选的 length 参数限定的子字符串使用 replacement 进行替换。

阅读全文