所以这是我的代码:
function csq($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(149),
"•");
$replace = array("'",
"'",
'"',
'"',
'-',
'•',
'•');
return str_replace($search, $replace, $string);
}
$username = csq($_POST["username"]);
$titletag = csq($_POST["titletag"]);
$keywordtag = csq($_POST["keywordtag"]);
$desctag = csq($_POST["desctag"]);
$content = csq($_POST["content"]);
据我所知,每个变量都应该使用指定名称的post变量,然后将其传递给csq()函数,该函数将替换特殊字符。
这没有发生。我写错了吗?
这是一个字符串:
• Went over key word list that was generated
o Ant1 highlighted approved words
o We should add a column to calculate the ratio between the number of queries vs. the number of results “in parenthesis”
答案 0 :(得分:0)
我应该写下我的功能:
function csq($string)
{
static $translation_table;
if(!$translation_table)
{
$translation_table = array();
$translation_table[chr(145)] = "'";
$translation_table[chr(146)] = "'";
$translation_table[chr(147)] = '"';
$translation_table[chr(148)] = '"';
$translation_table[chr(151)] = "_";
$translation_table[chr(149)] = "•";
$translation_table["â"] = "•";
$translation_table["€"] = "•";
$translation_table["¢"] = "•";
}
return str_replace(array_keys($translation_table), $translation_table, $string);
}