[英]& (ampersand) char in $_SESSION() array on var_dump()
I have a index.php
with a start_session();
我有一个带start_session();
的index.php
start_session();
at the top. 在顶部。
Then if you click on a menu item it calls a include();
然后,如果单击菜单项,则调用include();
page (lets say page B) . 页面(比如说B页) 。 There is no start_session();
没有start_session();
at the top of that page because I thought because its included I can omit it. 在该页面的顶部,因为我认为因为它包括我可以省略它。
in this page B there is a AJAX
call to call a scripts page related to page B . 在此页面B中,有一个AJAX
调用来调用与页面B相关的脚本页面。 On this page I would like to use a stored $_SESSION();
在这个页面上我想使用存储的$_SESSION();
variable containing the username to do some things. 包含用户名的变量来做一些事情。 I do start the page with... 我用...开始页面
if(session_id() == '') { session_start(); }
When I do a var_dump($GLOBALS);
当我做一个var_dump($GLOBALS);
on this scripts page it contains 在它包含的脚本页面上
'_SESSION' => & array (size=2) 'username' => string 'mo' (length=2) 'administrator' => string '0' (length=1)
My question is, What is the ampersand & 's chars meaning in this case? 我的问题是,什么是&符号的字符在这种情况下意义?
Can I use the $_SESSION();
我可以使用$_SESSION();
variables as normal in this case? 在这种情况下,变量是否正常?
It's a reference. 这是一个参考。
The ampersand (&) back references the array stored under the _SESSION
key in the $GLOBALS array, when you try and access $_SESSION
super global. 当您尝试访问$_SESSION
super global时,&符号(&)返回引用存储在$ GLOBALS数组中_SESSION
键下的数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.