Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Util\HTTP::encode()中的urlencode()/urldecode()成组操作的疑问 #31

Closed
acgrid opened this issue May 24, 2015 · 1 comment
Closed

Comments

@acgrid
Copy link
Contributor

acgrid commented May 24, 2015

其实并不明白加这段代码的作用
https://github.com/overtrue/wechat/blob/master/src/Wechat/Utils/Http.php#L267-276

从结果上说,这使得双引号在Util\JSON::encode()执行期间躲起来了。
一个情景是图文信息是可以使用HTML的,content中的双引号就杯具了QAQ

$src = '""';
var_dump(urlencode($src)); // string '%22%22' (length=6)
var_dump(urldecode(urlencode($src))); // string '""' (length=2)
@overtrue
Copy link
Collaborator

@acgrid 这段代码的作用是解决 < 5.4 版本的php 不支持json_encode的第二个参数:JSON_UNESCAPED_UNICODE

http://php.net/manual/zh/function.json-encode.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants