Re: [Zend Engine 2] destruct() question
| From: | Ferdinand Beyer | Date: | Fri, 09 Aug 2002 10:35:18 +0000 |
| Subject: | Re: [Zend Engine 2] destruct() question | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5624@lists.php.net to get a copy of this message | ||
On 9 Aug 2002 at 12:04, Assen Chorbadjiev wrote:
> Hi,
>
> well, is there a way to explicitly destroy the object from within the instance ?
>
> Thanks,
> Assen
No, I don't think so. At least since the delete statement was dropped.
Try to only save one reference of your object and unset() it (or
replace it with another value) to delete it.
Perhaps this is also possible (not tested):
<?php
class Object
{
function destroy(&$ref)
{
$ref = null;
}
function __destruct()
{
echo "Object deleted.";
}
}
$obj = new Object();
$obj->delete($obj);
?>
This may work - also I did not tested it - if there is only one variable
holding the object ($obj). But it would be easier to directly set $obj =
null instead of calling delete() :-)
--
Ferdinand Beyer
<fbeyer@clickhand.de>