這篇文章主要介紹了PHP如何實(shí)現(xiàn)使用星號(hào)替代用戶名手機(jī)和郵箱,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

PHP使用星號(hào)替代用戶名手機(jī)和郵箱這個(gè)在許多的活動(dòng)界面會(huì)看到如淘寶的購(gòu)物界面中的一些客戶的支付寶號(hào)都是隱藏掉的哦,下面我們來(lái)看一下它的使用方法吧.
<?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 = "phpfensi.com";
$email = "416148489@qq.com";
$phone = "18005152525";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/tupian/20230522/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以星號(hào)隱藏用戶名手機(jī)和郵箱</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" >首 頁(yè)</a></li>
<li><a href="http://www.phpfensi.com /templates" rel="external nofollow" >網(wǎng)站模板</a></li>
<li><a href="http://www.phpfensi.com /js" rel="external nofollow" >網(wǎng)頁(yè)特效</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" >精選網(wǎng)址</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">
<h3 class="title"><a href="http://www.phpfensi.com /js/548.html" rel="external nofollow" >教程: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>感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“PHP如何實(shí)現(xiàn)使用星號(hào)替代用戶名手機(jī)和郵箱”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來(lái)學(xué)習(xí)!
本文標(biāo)題:PHP如何實(shí)現(xiàn)使用星號(hào)替代用戶名手機(jī)和郵箱-創(chuàng)新互聯(lián)
分享地址:http://chinadenli.net/article18/shsgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、App設(shè)計(jì)、網(wǎng)站設(shè)計(jì)公司、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站設(shè)計(jì)、電子商務(wù)
聲明:本網(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í)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容