note 13885 added to language.oop.php
| From: | b dot ruecker at portunity dot de | Date: | Sun, 08 Jul 2001 13:22:38 +0000 |
| Subject: | note 13885 added to language.oop.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15092@lists.php.net to get a copy of this message | ||
If you need a destructor, perhaps it is an idear to simulate it this way with a global
Destroy-Function:
<?
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 ();
?>
http://www.php.net/manual/de/language.oop.php