dongziya9863 2014-08-08 13:55
浏览 13
已采纳

$ _GET for + in url get request?

My project Url is like this in yii:

 http://localhost/php_pro_106/activate/Test?JJ=HEY+OOO

In my action :

public function actionTest()
   {
   print_r($_GET);
 }

I am getting:

 Array ( [JJ] => HEY OOO )

But I should get:

 Array ( [JJ] => HEY+OOO ) 

What should I do for this,I need same Url ?

  • 写回答

3条回答 默认 最新

  • duanqiao0153 2014-08-08 13:59
    关注

    A + in a URL means a space. So you get the result you should have.

    If you want to encode a + character in a URL, then you should represent it as %2B.

    http://localhost/php_pro_106/activate/Test?JJ=HEY%2BOOO
    

    If you are generating the URL programatically with PHP, you can use the urlencode function.

    $keyname = "JJ";
    $data = "HEY+OOO";
    $url = "http://localhost/php_pro_106/activate/Test?" . urlencode($keyname) . "=" . urlencode($data);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题