esto estaba en la documentacion de POO online :
http://ar2.php.net/oop Código PHP:
<?
function DestroyObject ($name)
{
$theobject = &$GLOBALS[$name];
if (method_exists ($theobject,"Destroy"))
$theobject->Destroy ();
unset ($GLOBALS[$name]);
}
class xyz
{
var $somevar;
// ### This is the constructor
function xyz ()
{
}
// ### This is the destructor which will be called
function Destroy ()
{
echo ("Now we destroy it !");
}
function SomeDo ()
{
echo ("doing something: ".$this->somevar);
}
}
$example = new xyz;
// .... doing something here
$example->somevar = 3;
$example->SomeDo();
DestroyObject ("example");
// ### Test => should produce an error !
$example->SomeDo ();
?>