问题描述
我有一个像这样的 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"]
.
Dots and spaces in variable names are converted to underscores. For example
<input name="a.b" />
becomes$_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)
.
(dot) - 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 空格转换为下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!