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 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含
  • ¥15 麒麟V10桌面版SP1如何配置bonding
  • ¥15 Marscode IDE 如何预览新建的 HTML 文件