#36173 [Opn->Bgs]: Static Variable Not saved when object saved in $_Session

From: Date: Thu, 26 Jan 2006 19:52:09 +0000
Subject: #36173 [Opn->Bgs]: Static Variable Not saved when object saved in $_Session
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-92525@lists.php.net to get a copy of this message
ID: 36173 Updated by: helly@php.net Reported By: ismell at ismell dot org -Status: Open +Status: Bogus Bug Type: Session related Operating System: Linux 2.6 PHP Version: 5.1.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php you stored objects Previous Comments: ------------------------------------------------------------------------ [2006-01-26 20:36:31] ismell at ismell dot org Description: ------------ Then saving an object with a static variable in a session, when the session is reloaded, the variable is not set anymore. Reproduce code: --------------- <?php session_start(); class c1 { public static $ids = 1; private $id; public function __construct() { $this->id = c1::$ids++; } public function getId() { return $this->id; } } $_SESSION['test'][] = new c1(); $_SESSION['test'][] = new c1(); echo '<pre>Output:'; foreach ($_SESSION['test'] as $class) { echo $class->getId()."\n"; } echo '</pre>' ?> Expected result: ---------------- Output: 1 2 3 4 5 6 7 8 9 Actual result: -------------- Output: 1 2 1 2 1 2 1 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36173&edit=1

« previous php.bugs (#92525) next »