|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-01-26 20:52 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 13:00:01 2025 UTC |
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