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

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

Jun 13, 2016 am 10:20 AM
quot session time undefined variable

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()后才被定义的。在这之前,它不是超级全局变量。
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set session timeout in SpringBoot Session How to set session timeout in SpringBoot Session May 15, 2023 pm 02:37 PM

How to set session timeout in SpringBoot Session

How to solve session failure How to solve session failure Oct 18, 2023 pm 05:19 PM

How to solve session failure

Solution to PHP Session cross-domain problem Solution to PHP Session cross-domain problem Oct 12, 2023 pm 03:00 PM

Solution to PHP Session cross-domain problem

TypeError: Cannot read property '$XXX' of undefined in Vue, how to deal with it? TypeError: Cannot read property '$XXX' of undefined in Vue, how to deal with it? Nov 25, 2023 pm 12:14 PM

TypeError: Cannot read property '$XXX' of undefined in Vue, how to deal with it?

Monotonic clock processing of time package Monotonic clock processing of time package Aug 04, 2023 pm 05:45 PM

Monotonic clock processing of time package

Solution to PHP Notice: Undefined property: Solution to PHP Notice: Undefined property: Jun 22, 2023 pm 02:48 PM

Solution to PHP Notice: Undefined property:

How to correctly read and write Session data in multiple files with PHP How to correctly read and write Session data in multiple files with PHP Mar 23, 2023 am 11:12 AM

How to correctly read and write Session data in multiple files with PHP

How to implement SMS login in Redis shared session application How to implement SMS login in Redis shared session application Jun 03, 2023 pm 03:11 PM

How to implement SMS login in Redis shared session application

See all articles