3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php header('Content-type: text/html; charset=utf-8'); echo '<br />百度关键词URL编码转换示例:<br />'; $urlBaidu = 'http://www.baidu.com/s?wd=%D6%D0%CE%C4'; $arrParse = parse_url($urlBaidu); var_dump($arrParse); parse_str($arrParse ['query'],$output); echo '乱码:' . $output['wd'] . '<br />'; //将gb2312编码转换成utf-8编码 $strUTF8 = mb_convert_encoding($output['wd'], 'utf-8', 'gb2312'); echo '可读码:' . $strUTF8 . '<br />'; echo '<br />谷歌关键词URL编码转换示例:<br />'; $urlGoogle = 'http://www.google.cn/search?hl=zh-CN&source=hp&q=%E4%B8%AD%E6%96%87&aq=f&oq='; $arrParse = parse_url($urlGoogle); var_dump($arrParse); parse_str($arrParse ['query'],$output); //谷歌关键词URL编码是utf-8,不用再作转换 echo '可读码:' . $output['q'] . '<br />';
Output for 4.3.4 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<br />百度关键词URL编码转换示例:<br />array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.baidu.com" ["path"]=> string(2) "/s" ["query"]=> string(15) "wd=%D6%D0%CE%C4" } 乱码:����<br />可读码:中文<br /><br />谷歌关键词URL编码转换示例:<br />array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.google.cn" ["path"]=> string(7) "/search" ["query"]=> string(48) "hl=zh-CN&source=hp&q=%E4%B8%AD%E6%96%87&aq=f&oq=" } 可读码:中文<br />
Output for 4.3.2 - 4.3.3
<br />百度关键词URL编码转换示例:<br />array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.baidu.com" ["path"]=> string(2) "/s" ["query"]=> string(15) "wd=%D6%D0%CE%C4" } 乱码:����<br /> Warning: mb_convert_encoding(): Illegal character encoding specified in /in/BFTS4 on line 16 可读码:ÖÐÎÄ<br /><br />谷歌关键词URL编码转换示例:<br />array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.google.cn" ["path"]=> string(7) "/search" ["query"]=> string(48) "hl=zh-CN&source=hp&q=%E4%B8%AD%E6%96%87&aq=f&oq=" } 可读码:中文<br />
Output for 4.3.0 - 4.3.1
<br />百度关键词URL编码转换示例:<br />array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.baidu.com" ["path"]=> string(2) "/s" ["query"]=> string(15) "wd=%D6%D0%CE%C4" } 乱码:����<br /> Warning: mb_convert_encoding() [http://www.php.net/function.mb-convert-encoding]: Illegal character encoding specified in /in/BFTS4 on line 16 可读码:ÖÐÎÄ<br /><br />谷歌关键词URL编码转换示例:<br />array(4) { ["scheme"]=> string(4) "http" ["host"]=> string(13) "www.google.cn" ["path"]=> string(7) "/search" ["query"]=> string(48) "hl=zh-CN&source=hp&q=%E4%B8%AD%E6%96%87&aq=f&oq=" } 可读码:中文<br />