php cookie名不能使用点号(句号),应该说可以使用点号的cookie名,但会被转换,要知道为什么,祥看本文
这个标题不是很严格,应该说可以使用点号的cookie名,但会被转换,你命名一个cookie:
$_COOKIE[‘my.name'] = 1;
实际上你不能通过'my.name'在cookie中查找到这个值,只能是'my_name':
echo $_COOKIE[‘my_name'];
php已经自动帮你进行了转化,,句点转为了下划线。
php为什么要这样做呢?这是因为$_GET/$_POST/$_SERVER/$_COOKIE。。。这些全局函数的值,在之前的许多版本中是可以通过register_globals参数在本地中直接访问这些值的,比如开启register_globals = on后,访问$my_name直接取值为1。如果是$my.name的话,则不符合php变量命名原则,这不单是句号(.)的问题。
因此,$_COOKIE的命名已经符合php命名标准。
另外开启register_globals是一个很糟糕的决定,因为它可能会覆盖脚本中原来的值,比如:
// other code
if ($a)
$uc_is_login = true;
// ...
用户只需要发送一个url?a=1的http请求就可以默认已经登陆。这是个很危险的做法,应该把它关闭。实际上php6已经去除了这个选项。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment