On Aug 23, 2006, at 11:41 AM, Jochem Maas wrote:
you can still use OOP, only you can't rely on auto destruct with
regard to object existance.
try the ini settings auto_prepend_file auto_append_file
http://php.net/manual/en/ini.core.php#ini.auto-append-file
and use them to control the startup &/or shutdown phase of your
app. e.g:
class DB {
private $connObj; // obj of class DB
// don't allow references to it outside the class
static function shutdown() { unset(self::$connObj); /* trigger
self::__destruct() */ }
function __destruct() { /* do stuff (which you could just as well
do in self::shutdown()?) */ }
}
shutdown.php:
<?php
DB::shutdown();
Jochem,
That's a good idea, and I'm glad to learn about the auto-append-file
directive for the first time, but that seems a bit more "hack-ey"
than I want.
Just to document this a bit more, this page has a quote supposedly
from Andi Gutmans saying we "must not rely in any way on the order of
destruction during shutdown":
http://www.phpbuilder.com/board/archive/index.php/t-10293485.html
Previous bug reports on this issue:
http://bugs.php.net/bug.php?id=36034
http://bugs.php.net/bug.php?id=31326
Since these bugs don't appear to be slated for fixing, I submitted a
request to change the documentation:
http://bugs.php.net/bug.php?id=38572
The documentation ought to reflect that we cannot "rely on the the
order of destruction" rather than the current "The destructor method
will be called as soon as all references to a particular object are
removed", which is incorrect.
But I'd actually prefer that the bug be fixed rather than the
documentation changed.
Richard
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php