$_POST spaces converted in underscores($_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"].
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 空格转换为下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:$_POST 空格转换为下划线
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
