שיעור שני
תגיד לי איפה הבאג בקוד הזה ב PHP שלי???? מחר יש לך מבחן!
function bad_words($string,$lang) { // USAGE: // make a table called bad_words_lang and put inside a bad words (words, id, lang_id). // use :$a=language_filter($char,1); print_R($a); $string_orginal=$string; $count_total=count(explode(" ",$string)); $obscenities_db_q=mysql_query("select * from bad_words_lang where lang_id=’$lang’"); if (!$obscenities_db_q) { die(‘Invalid query: ‘ . mysql_error()); exit; } while($obscenities_db_r=mysql_fetch_array($obscenities_db_q)) { $obscenities[] =$obscenities_db_r[word]; } foreach ($obscenities as $curse_word) { if (stristr(trim($string),$curse_word)) { $string = eregi_replace($curse_word,"±¶´",trim($string)); $cur_found = substr_count ($string, ‘±¶´’); $Replaced = eregi_replace($curse_word,$stars,trim($string)); $Replaced=str_replace("±¶´","***",$Replaced); } } $make_percents=floor($cur_found/$count_total*100) return array( "orginal_text"=>"$string_orginal", "replaced_text"=>"$Replaced", "total_words"=>"$count_total", "found_count"=>"$cur_found", "found_percent"=>"$make_percents", "found_percent_syntax"=>"%$make_percents" ); } ?>