名称中带点的 PHP GET url 参数

标签 php

得到了一些似乎不起作用的东西。假设我有一个像

www.test1.php?WC.id=12345

然后下面什么都不返回

$_GET['WC.id'];

如果我卸下马桶。部分,然后它返回 12345。我的 url 参数名称中可以没有句点吗?

谢谢

最佳答案

来自documentation :

It is important to note that PHP will automatically replace any dots in incoming variable names with underscores. [...] PHP irreversibly modifies field names containing these characters in an attempt to maintain compatibility with the deprecated register_globals feature.

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

chr(32) ( ) (space)
chr(46) (.) (dot)
chr(91) ([) (open square bracket)
chr(128) - chr(159) (various)

因此,您可以使用WC_id 名称访问WC.id

关于名称中带点的 PHP GET url 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33126289/

相关文章:

php - 使用 JQuery 更改图像

PHP删除以wp_postpass_开头的cookie

javascript - HIGHCHARTS - Jquery/Ajax 从 ajax 调用的 php 文件访问 php 变量

php - 库作为 Codeigniter 中的单例?

javascript - 在 jQuery 中插入 PHP 变量

php - 如何在 mysql (laravel) 中使 varchar 可以为空且唯一

php - 大约 25 分钟后 session 丢失

php - 跨子域和主机的 Cookie

php - 将评论编号 anchor 附加到评论

PHP Foreach 和取消设置变量