Home > Backend Development > PHP Tutorial > Notice: Undefined variable: _SESSION,该如何解决

Notice: Undefined variable: _SESSION,该如何解决

WBOY
Release: 2016-06-13 13:33:23
Original
1187 people have browsed it

Notice: Undefined variable: _SESSION

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->echo $_SESSION['time']."<br>";
Copy after login

这句话报错。
Notice: Undefined variable: _SESSION 

但是加上赋值就不报错。并且可以显示出aa。
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$_SESSION['time'] = 'aa';
echo $_SESSION['time']."<br>";
Copy after login

不知什么原因。


------解决方案--------------------
$_SESSION是在调用session_start()后才被定义的。在这之前,它不是超级全局变量。
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