|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-08-15 15:10 UTC] helly@php.net
[2004-08-15 15:56 UTC] sampw at hotmail dot com
[2004-08-15 16:09 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
Description: ------------ Destructor is not called to late. If you use a singleton pattern unset does not work, because there exist a private static reference for the object. Why is the destructor called so unreliable? Is such a singleton pattern not possible in PHP? Or must the static $instance be public, inorder to unset it manually? (Not a nice solution?!) Reproduce code: --------------- class Session { //Db Session (Singleton) static private $instance = false; private function __construct() { } public function __destruct() { $this->sessionWriteClose(); // e.G. store session data } static function instance() { if(!Session::$instance) Session::$instance = new Session(); return Session::$instance; } } $OBJ_SESSION = Session::instance(); unset($OBJ_SESSION); // Does not work, because of the static private $instance