-
数据库utf8_general_ci不兼容utf8mb4字符
过滤utf8mb4字符:
$content = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $content);
-
ASCII码的控制字符导致json_decode 和 simplexml_load_string失效
过滤控制字符:
$decode_msg = preg_replace('/[\x00-\x1F\x7F-\x9F]/u', '', $decode_msg);
$content = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $content);
$decode_msg = preg_replace('/[\x00-\x1F\x7F-\x9F]/u', '', $decode_msg);