note 93221 added to function.register-shutdown-function

From: Date: Fri, 28 Aug 2009 21:52:59 +0000
Subject: note 93221 added to function.register-shutdown-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-160008@lists.php.net to get a copy of this message
This may seem obvious to many people, but don't register an object's __destruct() function as a shutdown function! In many instances, it will then call the destructor twice, most likely on an already destroyed object! For example, you might get this error: PHP Warning: mysqli::close() [<a href='function.mysqli-close'>function.mysqli-close</a>]: Couldn't fetch mysqli in /path/to/file.php I saw docey's comment from 2006 in this very page where they do just that, and this more often than not cause problems! It would be wise to look out for old code where someone has done that very thing then too! ---- Server IP: 216.235.13.26 Probable Submitter: 66.11.84.187 ---- Manual Page -- http://www.php.net/manual/en/function.register-shutdown-function.php Edit -- https://master.php.net/note/edit/93221 Del: integrated -- https://master.php.net/note/delete/93221/integrated Del: useless -- https://master.php.net/note/delete/93221/useless Del: bad code -- https://master.php.net/note/delete/93221/bad+code Del: spam -- https://master.php.net/note/delete/93221/spam Del: non-english -- https://master.php.net/note/delete/93221/non-english Del: in docs -- https://master.php.net/note/delete/93221/in+docs Del: other reasons-- https://master.php.net/note/delete/93221 Reject -- https://master.php.net/note/reject/93221 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160008) next »