我試圖只允許標(biāo)題中的特定符號,這是通過 ajax 調(diào)用提交的,所以我使用的是 preg_match,但事實(shí)證明撇號正在通過編碼 - ',所以我的 preg_match 沒有看到它。if (strlen($_POST["meta"]) < 101 && preg_match("/^[a-zA-Z0-9'\-\+:,!&. ]+$/", $_POST["meta"])) { //update post title code}什么是正確的解決方法?
1 回答

喵喵時(shí)光機(jī)
TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊
所以,我用html_entity_decode做到了這一點(diǎn)
$title = $_POST["meta"];
$title = html_entity_decode($title);
if (strlen($title) < 101 && preg_match("/^[a-zA-Z0-9'\-\+:,!&. ]+$/", $title)) {
//update post title code
}
- 1 回答
- 0 關(guān)注
- 179 瀏覽
添加回答
舉報(bào)
0/150
提交
取消