$ _POST下划线转换为空格 [英] $_POST spaces converted in underscores

查看:141
本文介绍了$ _POST下划线转换为空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下所示的HTML下拉菜单

I have an HTML dropdown menu that looks like this

<select name='not working random test!'>
<option value='0'>Select quantity:</option>
<option value='1'>1 room</option>
<option value='2'>2 rooms</option>
</select>

如果我是var_dumping $ _POST,是否有可能看到类似的东西?

Is it even possible that, if I'm var_dumping $_POST, I see something like this?

["not_working_random_test!"]=>
string(1) "1"

这给我的引擎造成了一些麻烦:我希望我为选择指定的名称是相同的.为什么这没有发生?

This is causing some troubles with my engine: I expect the name I specify for the select to be the same. Why is this not happening?

推荐答案

这是标准的PHP行为.从文档:

This is standard PHP behaviour. From the documentation:

变量名中的点和空格将转换为下划线.例如,<input name="a.b" />变为$_REQUEST["a_b"].


PHP转换为_(下划线)的字段名称字符的完整列表如下(不仅仅是点):


The full list of field-name characters that PHP converts to _ (underscore) is the following (not just dot):

  • chr(32)(空格)
  • chr(46).(点)
  • chr(91)[(方括号)
  • chr(128)-chr(159)(多种)
  • chr(32) (space)
  • chr(46) . (dot)
  • chr(91) [ (open square bracket)
  • chr(128) - chr(159) (various)

如果同时存在方括号,则不会转换它们,但是$ _POST元素将成为数组元素.

If both an open and a closing square bracket are present, they are not converted but the $_POST element becomes an array element.

<input name='hor[se'>
<input name='hor[se]'>

将变为:

$_POST['hor_se'];
$_POST['hor']['se'];

::: 参考

这篇关于$ _POST下划线转换为空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆