BAD Word Filter with PHPbad word mang nyEbelin kalo di komen2 ada karakter2 berbahaya kaya petik dua petik satu dan slash.
Sebenernye kalo nyang pernah gw baca di forum
phpbuilder.comdengan menggunakan strip tags aja dah aman, tapi ada baikna kalo security form di lipatgandakan. mudah2an si berguna walopun fungsi bwatan gw ni cuma beberapa baris
function wordFilter($strToFilter)
{
$strToFilter = str_replace("'", "", $strToFilter);
$strToFilter = str_replace(" ", " ", $strToFilter);
$strToFilter = str_replace('"', "", $strToFilter);
$strToFilter = str_replace("|", "", $strToFilter);
$strToFilter = str_replace("\'", "", $strToFilter);
$strToFilter = str_replace("\"", "", $strToFilter);
$strToFilter = str_replace("\\", "", $strToFilter);
$strToFilter = str_replace("/", "", $strToFilter);
return $strToFilter;
}
contoh penggunaan:
echo 'String lu: ';
echo $str = "Thank\"s 'Brother' !";
echo '<BR> Dengan Filter akan menjadi: ';
echo wordFilter($str); //hasilna: Thanks Brother !