我有以下功能,但结果仍然给我string(13) "hell'o"o"
而不是特殊字符
功能:
private function makeHTMLSpecial($input)
{
return htmlentities(trim($input), ENT_QUOTES);
}
代码:
$new_descriptionCheck = $this->input->post('desc');
$new_description = $this->makeHTMLSpecial($new_descriptionCheck);
答案 0 :(得分:0)
你的包围正确吗?
private function makeHTMLSpecial($input)
{
return htmlentities(trim($input), ENT_QUOTES);
}
测试字符串长度......
$string = "hell'o\"o";
var_dump($string); // string 'hell'o"o' (length=8)
var_dump(htmlspecialchars($string)); // string 'hell'o"o' (length=13)