st"/>  st">
Home > Backend Development > PHP Tutorial > PHP session 的奇怪守则

PHP session 的奇怪守则

WBOY
Release: 2016-06-13 12:57:30
Original
834 people have browsed it

PHP session 的奇怪规则

<br />
	session_start();<br />
	var_dump($_SESSION);<br />
	$name = 'laruence';<br />
	$_SESSION['name'] = null;<br />
Copy after login

输出: array(1) { ["name"]=> string(8) "laruence" }

$name 和 $_SESSION['name']是八竿子打不着的两个变量, 它凭什么给弄成等同于同一个变量, 发明PHP那人脑残吧. 


------解决方案--------------------
引用:
引用:PHP code?12345

输出:
array(1) { ["name"]=> NULL }


是你自己把register_glob……


是我错了,这个问题与register_global无关。不过我的5.4版本就没有这个问题,5.4也已经没有register_global这个选项了。你这代码貌似引用自laruence的博客:http://www.laruence.com/2009/07/13/976.html

他在里面已经解释了原因。在session.bug_compat_42开启的情况下, PHP会认为变量name是$_SESSION['name']的一个引用, 在session_close的时候, 会把变量a的值回写。
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