PHP Development Tips (11)-Sample code for php to implement mobile phone number display part

黄舟
Release: 2023-03-06 13:56:02
Original
1290 people have browsed it

From the perspective of personal information protection, we will always find ways to protect some of the users' personal information during the development process. As mentioned in this blog post, we sometimes display only part of the user's mobile phone number. This is a function that many websites have. This function is also very simple to implement. We only need to intercept the mobile phone number and then fill in the middle part with "*".

The following is the implementation code:

<?php  
/** 
 * ======================================= 
 * Created by Zhihua_W. 
 * Author: Zhihua_W 
 * Date: 2017/2/8 0007 
 * Time: 上午 8:34 
 * Project: PHP开发小技巧 
 * Power: php实现手机号码部分显示 
 * ======================================= 
 */  
  
$mobile = "18000000001";  
//保留前三位和后三位   
$new_mobile = substr($mobile, 0, 3) . &#39;*****&#39; . substr($mobile, 8, strlen($mobile));  
  
echo $new_mobile;  
//结果输出:180*****001
Copy after login


The above is the detailed content of PHP Development Tips (11)-Sample code for php to implement mobile phone number display part. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!