Solve the problem of Chinese json encoding fuzzy query in php

WBOY
Release: 2016-08-08 09:25:34
Original
1090 people have browsed it

json格式中文解码查询

这里有一坑,mysql 在查询的时候自动将'\' 做特殊字符处理了

需要四个 \\\\ 进行转换转义

$username = json_encode($username);
$username = str_replace('\\','\\\\\\\\',trim($username, '"'));
$where = $where . ' and wb_bp_users.`name` like \'%' . $username . '%\'';
Copy after login

详细信息可参考这问仁兄的博客:

http://my.oschina.net/qii/blog/196532

以上就介绍了php中解决中文json编码模糊查询问题,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

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