duanchi1230 2014-10-10 09:46
浏览 580
已采纳

$ _GET无法使用& 在URL中

Im working on a Wix widget. The iframe containing my widget has this URL generated by Wix:

http://domain.com/wix/widget/?cacheKiller=123456&compId=hyeddksh&deviceType=desktop&instance=xxxxxxxxxxxxxx&locale=en&viewMode=editor&width=50

I tried retriving the instance and compId values from the URL using $_GET but no luck.

echo '<pre>';
    print_r($_GET);
echo '</pre>';

gives me

Array
(
    [cacheKiller] => 123456
    [amp;compId] => hyeddksh
    [amp;deviceType] => desktop
    [amp;instance] => xxxxxxxxxxxxxx
    [amp;locale] => en
    [amp;viewMode] => editor
    [amp;width] => 50
)

Any idea about retrieving these values without using $_GET[amp;compId] and $_GET[amp;instance]?

EDIT To solve my issue, I am using $compId = isset($_GET['compId']) ? $_GET['compId'] : $_GET['amp;compId'];which I believe is not the right way. Anyone?

  • 写回答

1条回答 默认 最新

  • doukui9491 2014-10-10 10:02
    关注

    As a mega quick and dirty hack, you could use array_walk.

    array_walk($_GET, function($value, $key) use(&$_GET) {
         $_GET[str_replace('amp;', '', $key)] = $_GET[$key];
         unset($_GET[$key]);
    });
    

    <kbd>See it in action</kbd>

    Then you can use the keys without the amp; prefix.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿