I like to cleanly handle the destruction of all objects on script termination.
This is very useful when developing because I can 'round up' all the errors
even when the script fails.
At the moment I am explicitly naming the objects in a shutdown function
and accessing them globally: Example
This works but requires a shutdownFunc() for every project
because diiferent objects are created..
I am now working on the idea of making shutdownFunc() a top-level class::method
used by all projects but this means finding all objects dynamically.
The closest I can think is using get_defined_var s() then is_object().
Is there a better way or even a better idea?
This is very useful when developing because I can 'round up' all the errors
even when the script fails.
At the moment I am explicitly naming the objects in a shutdown function
and accessing them globally: Example
Code:
function shutdownFunc()
{
global $mysql;
if(is_object($mysql))
disconnectDB($mysql,$errorlist);
global $mssql;
if(is_object($mssql))
disconnectDB($mssql,$errorlist);
}
because diiferent objects are created..
I am now working on the idea of making shutdownFunc() a top-level class::method
used by all projects but this means finding all objects dynamically.
The closest I can think is using get_defined_var s() then is_object().
Is there a better way or even a better idea?
Comment