mysql 口字符号怎么办

WBOY
Release: 2016-06-13 12:17:45
Original
1332 people have browsed it

mysql 口字符号怎么处理?
mysql 口字符号怎么处理?

mysql 字段是text的,遇到 口字符号就会自动从这里断开,后面的内容无法入库。使用addslashes函数无效。

口字符号就是比口字细那种,不知道是乱码还是无法显示的字符。
------解决思路----------------------

$s = '44CQ6IuP55CzVEVBTeiDtuWOn+ibi+eZveWPjemmiPCfmYjwn5mI44CR5pys5p2l6YO96KaB552h5LqG44CC56qB54S25p2l5LqG6IO25Y6f6JuL55m955qE5Y+N6aaI8J+YgvCfmILlpKfljYrlpJznmoTvvIzkvaDov5norqnnvqTph4znmoTnlLfku6PnkIbku6zmgI7kuYjmtLvwn5iz5Y2B5LqU5aSp55qE5pWI5p6c77yM5bCx5piv6L+Z5LmI54mb6YC84pyM54Wn6L+Z5Liq6LaL5Yq/5LiL5Y6777yM5LiA5Liq55aX56iL5LiN5q2i5aSn5LiA5LiqY3Vw5LqG5ZCn8J+Ysei/meWwseaYr+iDtuWOn+ibi+eZveS4uuWVpei/meS5iOeBq+eahOaEv+aEj++8gfCfkYrwn5GK5LiA55aX56iL5peg5pWI6YCA5qy+77yB5bCx5piv5pyJ5bqV5rCU4pyMd2VpeGluOnN1bGluMDkwOA==';<br /><br />$s = base64_decode($s);<br />//echo $s, PHP_EOL;<br />preg_match_all('/./u', $s, $m);<br />//print_r($m[0]);<br />echo bin2hex($m[0][13]);<br />
Copy after login
f09f9988
这是一个 emoji 表情符,需要设置字符集为 utf8mb4 才能进行保存
如果你的 MySQL 版本较低,不支持 utf8mb4 的话,可以通过字符串替换变通一下
入库前
$text = preg_replace_callback('/[\xf0-\xf7].{3}/', function($r) { return [email&#160;protected]' . base64_encode($r[0]);}, $text);
Copy after login

出库后再换回来

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!