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

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

WBOY
WBOYOriginal
2016-06-13 10:20:081153browse

Notice: Undefined variable: _SESSION

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->echo $_SESSION['time']."<br>";

这句话报错。
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>";

不知什么原因。


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