国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

PHP使用星號隱藏用戶名,手機和郵箱的實現方法

2024-05-04 23:49:56
字體:
來源:轉載
供稿:網友

本文實例講述了PHP使用星號隱藏用戶名,手機和郵箱的實現方法。分享給大家供大家參考,具體如下:

PHP使用星號替代用戶名手機和郵箱這個在許多的活動界面會看到如淘寶的購物界面中的一些客戶的支付寶號都是隱藏掉的哦,下面我們來看一下它的使用方法吧.

<?phpfunction hideStar($str) { //用戶名、郵箱、手機賬號中間字符串以*隱藏  if (strpos($str, '@')) {    $email_array = explode("@", $str);    $prevfix = (strlen($email_array[0]) < 4) ? "" : substr($str, 0, 3); //郵箱前綴    $count = 0;    $str = preg_replace('/([/d/w+_-]{0,100})@/', '***@', $str, -1, $count);    $rs = $prevfix . $str;  } else {    $pattern = '/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i';    if (preg_match($pattern, $str)) {      $rs = preg_replace($pattern, '$1****$2', $str); // substr_replace($name,'****',3,4);    } else {      $rs = substr($str, 0, 3) . "***" . substr($str, -1);    }  }  return $rs;}?><?php$account = "vevb.com";$email = "123456789@qq.com";$phone = "13888888888";?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <title>演示:PHP以星號隱藏用戶名手機和郵箱</title>    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>    <link rel="stylesheet" type="text/css" href="css/common.css" />    <style type="text/css">    </style>  </head>  <body>    <div class="head">      <div class="head_inner clearfix">        <ul id="nav">          <li><a href="/">首 頁</a></li>          <li><a href="/templates">網站模板</a></li>          <li><a href="/js">網頁特效</a></li>          <li><a href="/php">PHP</a></li>          <li><a href="/site">精選網址</a></li>        </ul>        <a class="logo" href=""><img src="images/logo.jpg"      </div>    </div>    <div class="container">      <div class="demo">        <h2 class="title"><a href="#">教程:PHP以星號隱藏用戶名手機和郵箱</a></h2>        <table width="100%" class="table_parameters">          <tr class="tr_head">            <td>賬號</td>            <td>郵箱</td>            <td>手機</td>          </tr>          <tr>            <td><?php echo $account; ?></td>            <td><?php echo $email; ?></td>            <td><?php echo $phone; ?></td>          </tr>          <tr class="red">            <td><?php echo hideStar($account); ?></td>            <td><?php echo hideStar($email); ?></td>            <td><?php echo hideStar($phone); ?></td>          </tr>        </table>      </div>    </div>  </body></html>

希望本文所述對大家PHP程序設計有所幫助。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 高州市| 盐城市| 固始县| 望城县| 垦利县| 讷河市| 昭苏县| 永善县| 吉水县| 德阳市| 固始县| 汽车| 阿合奇县| 南和县| 都江堰市| 光山县| 博客| 静安区| 昭平县| 离岛区| 航空| 阿拉尔市| 清丰县| 天镇县| 收藏| 大渡口区| 洪洞县| 西丰县| 双江| 民乐县| 宣恩县| 宁远县| 哈巴河县| 云阳县| 阳高县| 漠河县| 平昌县| 桑植县| 乳山市| 获嘉县| 远安县|