关于$_SESSION['verify']的迷惑

WBOY
Release: 2016-06-06 20:07:31
Original
1034 people have browsed it

关于$_SESSION['verify']的迷惑

为什么表单提交之后session的值会是post传过去的值呢?
换个名字都可以正常,唯独用verify会出现这种现象

回复内容:

关于$_SESSION['verify']的迷惑

为什么表单提交之后session的值会是post传过去的值呢?
换个名字都可以正常,唯独用verify会出现这种现象

这很可能是PHP的一个Bug。

因为$_SESSION中的变量保存使用的是引用,当register_globals设置为on的时候,如果全局变量中有名字和$_SESSION中的变量名一样(比如你的代码中的$verify变量和$_SESSION['verity']这两个verify),PHP会有不可预料的行为发生。所以,你的这个问题不是POST过去的值传到了$_SESSION中,而是$_SESSION['verify']错误地引用了全局的$verify变量。

这在PHP的官方文档下用户的Comment中提到多次:
http://php.net/manual/en/reserved.variables.session.php

Post 的值是从表单传过去的

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!