<kbd id='woaibaidu'></kbd><address id='woaibaidu'><style id='woaibaidu'></style></address><button id='woaibaidu'></button>

          当前位置:主页 > 网络编程 > PHP编程 >
            PHP使用星号替代用户名手机和邮箱的实现代码
            2018-02-12 22:02 发布 次浏览

          PHP运用星号替换用户名手机和邮箱这个在许多的运动界面会看到如淘宝的购物界面中的1些客户的领取宝号都是隐藏掉的哦,上面我们来看1下它的运用办法吧.

          <?php 
          function 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, ⑴, $count); 
              $rs = $prevfix . $str; 
            } else { 
              $pattern = '/(1[3458]{1}[0⑼])[0⑼]{4}([0⑼]{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, ⑴); 
              } 
            } 
            return $rs; 
          } 
          ?> 
          <?php 
          $account = "phpfensi.com"; 
          $email = "[email protected]"; 
          $phone = "18005152525"; 
          ?> 
          <!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⑻" /> 
              <title>演示:PHP以星号隐藏用户名手机和邮箱</title> 
              <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> 
              <link rel="stylesheet" type="text/css" href="http://www.phpfensi.com /jquery/css/common.css" rel="external nofollow" /> 
              <style type="text/css"> 
              </style> 
            </head> 
            <body> 
              <div class="head"> 
                <div class="head_inner clearfix"> 
                  <ul id="nav"> 
                    <li><a href="http://www.phpfensi.com " rel="external nofollow" rel="external nofollow" >首 页</a></li> 
                    <li><a href="http://www.phpfensi.com /templates" rel="external nofollow" >网站模板</a></li> 
                    <li><a href="http://www.phpfensi.com /js" rel="external nofollow" >网页殊效</a></li> 
                    <li><a href="http://www.phpfensi.com /php" rel="external nofollow" >PHP</a></li> 
                    <li><a href="http://www.phpfensi.com /site" rel="external nofollow" >精选网址</a></li> 
                  </ul> 
                  <a class="logo" href="http://www.phpfensi.com " rel="external nofollow" rel="external nofollow" ><img src="http://www.phpfensi.com /Public/images/logo.jpg" alt="素材火logo" /></a> 
                </div> 
              </div> 
              <div class="container"> 
                <div class="demo"> 
                  <h2 class="title"><a href="http://www.phpfensi.com /js/548.html" rel="external nofollow" >教程: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运用星号替换用户名手机和邮箱的完成代码,希望对各人有所协助,假如各人有任何疑问请给我留言,小编会实时回复各人的。在此也十分感激各人对聚合网网站的支持!