直接正则过滤好了
$text = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $text);
=======
我数据库表编码是utf8_general_ci
当插入数据时有特殊字符时就报错了:
An exception occurred while executing 'UPDATE user_order SET update_time = ?, memo = ? WHERE id = ?' with params [1513996274, \"\\u5fae\\u4fe1 \\ud83c\\udf4eDGTyy\", 224]:\n\nSQLSTATE[HY000]:
General error: 1366 Incorrect string value: '\\xF0\\x9F\\x8D\\x8EDG...' for column 'memo' at row 1
1 回答
![?](http://img1.sycdn.imooc.com/545846070001a15002200220-100-100.jpg)
GCT1015
TA贡献1827条经验 获得超4个赞
建议全部转为utf8mb4
编码。
ALTER TABLE <table_name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- 1 回答
- 0 关注
- 448 浏览
添加回答
举报
0/150
提交
取消