我一直想知道如何將在網站上註冊的用戶的用戶名更改爲完全不同的東西,如果它有不好的單詞。我有與此類似的是這樣的東西:PHP註冊用戶名更改
$BadWords = array("badword1", "badword2", "badword3", "badword4", "badword5", "badword6", "badword7", "badword8", "badword9", "badword10", "badword11", "badword12", "badword13", "badword14", "badword15", "badword16", "badword17", "badword18", "badword19", "badword20", "badword21", "badword22", "badword23", "badword24", "badword25", "badword26", "badword27", "badword28", "badword29","badphrase" ,"badword30","badword31","badword32");
$Var = "[ContentRemoved]";
$title = str_replace($BadWords,$Var, $Username);
$Username = str_replace($BadWords,$Var, $Username);
這樣做的問題是,如果有人輸入用戶名,如「gobadword23」將其改爲「去[ContentRemoved]」。
我希望它做的是用「[ContentRemoved]」替換WHOLE用戶名。而不僅僅是壞話。
不好主意,總是可以繞過。相當令人反感,你認爲這些詞的一些'壞' – 2014-01-12 22:27:37
你看過嗎? http://stackoverflow.com/questions/4366730/how-to-check-if-a-string-contains-specific-words – x20mar
「分析」,「猶太人」,「公雞」和「玻璃」這些詞都是禁止的太? – halfer