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 三维直角坐标系下,给定一个平面内四个点坐标,如何将四个点逆时针排序
    • ¥15 UnityWebRequest访问内网地址502
    • ¥20 Python语言来实现牛顿法(Newton's Method)解决非线性(系统)方程的问题。
    • ¥15 matlab控制工业相机采集图像
    • ¥25 R里做折线图和柱状图
    • ¥20 使用kokkos移植项目,遇到问题
    • ¥15 求该问题的Matlab代码
    • ¥15 python下使用pdpbox为何提示has no attribute 'pdp_isolate'?
    • ¥15 求java web病房管理系统项目,用netbeans做的
    • ¥15 python图片画不出来