|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-03-01 20:10 UTC] mfischer@php.net
[2002-06-09 19:16 UTC] mfischer@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 15:00:01 2025 UTC |
Another unfortunate bug with references appears to be that statics holding references inside methods are actually transient, and a reference will be lost. For example, calling the following code several times will initialise $db and return every time with a new instance. function &getInstance() { static $db; if (!isset($db)) { $db =& new FS_DB(); } return $db; } whereas the following will give true singeton behaviour and initialise just once, as expected. function &getInstance() { static $db; if (!isset($db)) { $db = new FS_DB(); } return $db; }