问题描述
|
我将如何更改此功能,以便允许使用单撇号和连字符:
function sanitize_string($s) {
$result = preg_replace(\"/[^a-zA-Z0-9]+/\",\" \",html_entity_decode($s,ENT_QUOTES));
return $result;
}
解决方法
仅在范围的末尾添加单撇号和连字符:
function sanitize_string($s) {
$result = preg_replace(\"/[^a-zA-Z0-9\'-]+/\",\" \",html_entity_decode($s,ENT_QUOTES));
return $result;
}
,试图尽快给您答复。
我认为您可以将它们添加到角色类中。可能您需要逃脱它们。
注意:要使用“ 2”,请务必将其放在最后,否则它将被视为元字符。