|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-01 12:33 UTC] itotakas at msu dot edu
Description:
------------
$_SESSION variable should be "array" and "super global".
However, within the __destrunct function, $_SESSION changes its value to the reference to the class which implements __destruct function.
[Example]
<?
session_start();
$_SESSION["test"] = "test string";
class test {
function __destruct()
{
// $_SESSION = $this !?
print_r($_SESSION);
}
}
$test = new test;
?>
[Expected result]
Array ( [test] => test string )
[Actual result]
test Object ( )
Reproduce code:
---------------
<?
session_start();
$_SESSION["test"] = "test string";
class test {
function __destruct()
{
// $_SESSION = $this !?
print_r($_SESSION);
}
}
$test = new test;
?>
Expected result:
----------------
Array ( [test] => test string )
Actual result:
--------------
test Object ( )
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 02:00:01 2025 UTC |
The problem will occur when any super global is used from within __destruct. Here is a simpler example: <?php class test { function __destruct() { print_r($_ENV); } } $test = new test(); ?>