Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/02/2005, 21:08
Avatar de Nefertiter
Nefertiter
 
Fecha de Ingreso: enero-2003
Ubicación: Rosario
Mensajes: 1.316
Antigüedad: 23 años, 9 meses
Puntos: 9
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 (); 

?>