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

$ _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?

图片转代码服务由CSDN问答提供 功能建议

我正在处理Wix小部件。 包含我的小部件的iframe具有由Wix生成的URL:

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

我尝试从中恢复实例和compId值 使用$ _GET但没有运气的URL。

  echo'&lt; pre&gt;'; 
 print_r($ _ GET); 
echo'&lt; / pre&gt;'; \  n   
 
 

给我

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

有关检索这些值的任何想法 使用 $ _ GET [amp; compId] $ _ GET [amp; instance]

编辑 要解决我的问题,我使用 $ compId = isset($ _ GET ['compId'])? $ _GET ['compId']:$ _GET ['amp; compId']; 我认为这不是正确的方法。 有人吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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]);
    });
    

    See it in action

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

    打赏 评论

相关推荐 更多相似问题