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 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'