實(shí)現(xiàn)注冊(cè)用戶名必須中文

2024-07-17 23:49 更新

為了獲取更多最新內(nèi)容及功能更新,請(qǐng)直接訪問我們的首頁以查看DzzOffice筆記的最新地址。

在注冊(cè)頁實(shí)現(xiàn)用戶名必須為中文才能注冊(cè)方法原代碼

function check_username($username) { $guestexp = '^Guest'; $len = dstrlen($username); if ($len < 3 || preg_match("/^c:\\con\\con|[%,\*\"\<\>\&]|$guestexp/is", $username)) { return FALSE; } else { return TRUE; } }

修改后的代碼

function check_username($username) { $guestexp = '^Guest'; $len = dstrlen($username); if ($len < 3 || preg_match("/[u4e00-u9fa5]/i", $username)) { return FALSE; } else { return TRUE; } }


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)