dongshan4316 2014-04-19 13:38
浏览 51
已采纳

PHP:isset()不检测GET变量

I have an html form (method = "get", action = "cart.php") in which I use two buttons to send the same form.

echo '<input type="image" src="data/images/back.png" height="40px" id="back" name="back">';
echo '<input type="image" src="data/images/continue.png" height="40px" id="go" name="go">';

now, on the PHP side, I'd like to check which one of the button was clicked (the "go" button or the "back" button).

I've done:

if(isset($_GET['go.x']) == true)
{
   echo 'form submitted using button GO';
}
else
{
   echo 'form submitted using button BACK';
}

I use the 'go.x' variable name as the form is passing an "go.x" and "go.y" variables (the exact x,y positions inside the image button where the user clicked)

However, the isset() function always return false... how it could be? thanks

  • 写回答

3条回答 默认 最新

  • douxiong5972 2014-04-19 13:58
    关注

    From the manual:

    Because foo.x and foo.y would make invalid variable names in PHP, they are automagically converted to foo_x and foo_y. That is, the periods are replaced with underscores. So, you'd access these variables like any other described within the section on retrieving variables from external sources. For example, $_GET['foo_x'].

    There's an open issue raised against this replacement of periods with underscores in PHP that suggests that the behaviour was intended to translate submitted variable names into valid global names when register_globals is turned on.

    Now that the deprecated register_globals is finally being removed, it looks like there's a chance the behaviour will be changed to the one you were expecting all along.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?