2014-10-10 86 views
0

我正在使用Wix小部件。包含我的插件的iframe中有这个URL由维克斯产生:

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

我试着使用$ _GET但没有运气的URL retriving实例和compId值。

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

给我

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

有关检索,而不使用$ _GET这些数值任何想法[AMP; compId]$ _GET [AMP;实例]

编辑 为了解决我的问题,我使用$compId = isset($_GET['compId']) ? $_GET['compId'] : $_GET['amp;compId'];我相信这是不正确的做法。任何人?

+0

'$ _GET ['compId']'有什么问题? – andyroo 2014-10-10 09:49:23

+0

$ _GET ['compId']没有定义 – Lomse 2014-10-10 09:50:07

+0

那么,出于某种原因,&被越狱到html实体名称中,我假设Wix。为什么你将它转义为html实体名称?为什么不只有'&'而不是'&'? – andyroo 2014-10-10 09:55:28

回答

3

作为大型快速和肮脏的劈,你可以使用array_walk

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

See it in action

然后你可以使用按键没有amp;前缀。