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

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

黄舟
黄舟Original
2017-03-10 18:59:061344browse

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


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!

Statement:
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