這篇文章給大家分享的是有關(guān)PHP如何使用星號(hào)隱藏用戶名,手機(jī)和郵箱的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
具體如下:
PHP使用星號(hào)替代用戶名手機(jī)和郵箱這個(gè)在許多的活動(dòng)界面會(huì)看到如淘寶的購(gòu)物界面中的一些客戶的支付寶號(hào)都是隱藏掉的哦,下面我們來看一下它的使用方法吧.
<?php function hideStar($str) { //用戶名、郵箱、手機(jī)賬號(hào)中間字符串以*隱藏 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 = "jb51.net"; $email = "123456789@qq.com"; $phone = "13888888888"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/tupian/20230522/xhtml1-transitional.dtd"> <html xmlns="/tupian/20230522/logo.jpg" alt="素材火logo" /></a> </div> </div> <div class="container"> <div class="demo"> <h3 class="title"><a href="#">教程:PHP以星號(hào)隱藏用戶名手機(jī)和郵箱</a></h3> <table width="100%" class="table_parameters"> <tr class="tr_head"> <td>賬號(hào)</td> <td>郵箱</td> <td>手機(jī)</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>
感謝各位的閱讀!關(guān)于“PHP如何使用星號(hào)隱藏用戶名,手機(jī)和郵箱”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
分享文章:PHP如何使用星號(hào)隱藏用戶名,手機(jī)和郵箱-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://chinadenli.net/article6/cdjhog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)站設(shè)計(jì)、網(wǎng)站改版、網(wǎng)站維護(hù)、Google、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容
營(yíng)銷型網(wǎng)站建設(shè)知識(shí)