本文 12188 pv
0
今天在做百度音乐采集的时侯发现file_get_contents放一个URL读页面内容时报错,原来给的URL是JS编码的URL。解决办法就是用以下面的代码解决。
如:$stringHtmlContent = file_get_contents(encodeURI($url));
代码如下:jscoding.rar (已下载 1495 次)
引用地址为:http://www.captain.at/howto-php-urlencode-javascript-decodeURIComponent.php
PHP实现js编码的URL转换
© kekehu / 技术资源 / 2009.05.06 / 15:25 / 12188PV
PHP实现js当中的rawurlencode encodeURI encodeURIComponent 和 rawurldecode decodeURI decodeURIComponent 的URL编码转换今天在做百度音乐采集的时侯发现file_get_contents放一个URL读页面内容时报错,原来给的URL是JS编码的URL。解决办法就是用以下面的代码解决。
如:$stringHtmlContent = file_get_contents(encodeURI($url));
代码如下:jscoding.rar (已下载 1495 次)
引用地址为:http://www.captain.at/howto-php-urlencode-javascript-decodeURIComponent.php
本文有 0 篇评论
发表你的见解