开发者

When I json_encode an array of URLs it replaces periods with underscores

What caus开发者_如何学Ces json_encode() to replace periods with underscores? I can't have it doing this in my script as it then breaks my curl calls that use the URL array.


Works for me:

>> json_encode(array('www.url.com','mail.google.com/mail/?hl=en&tab=wm'));
'["www.url.com","mail.google.com\\/mail\\/?hl=en&tab=wm"]'

It's not json_encode(). Something else is doing this.


When PHP receives POST/GET variables (which I assume this is about, because json_encode wont't do it), replaces dots in keys with an underscore (a register_globals legacy I think).

Either work around it, or manually parse either $_SERVER['QUERY_STRING'] for GET's or file_get_contents('php://input'); for POST.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜