RE: [PHP] Deleting Objects
| From: | John Coggeshall | Date: | Thu, 03 Apr 2003 05:44:01 +0000 |
| Subject: | RE: [PHP] Deleting Objects | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142075@lists.php.net to get a copy of this message | ||
>How does one delete an object? For example:
>
> $object = new Class(...);
> .....
> $object = new Class(...);
PHP deletes any variable which is no longer referenced in memory.. So in
this case the first object that the variable $object pointed to will
automatically be destroied. If you want to force a variable to be
destroied, just unset() it.
So No it's not possible to "orphan" any object or variable in PHP.
John
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
John Coggeshall
john at coggeshall dot org http://www.coggeshall.org/
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
>-----Original Message-----
>From: trlists@clayst.com [mailto:trlists@clayst.com]
>Sent: Thursday, April 03, 2003 12:07 AM
>To: php-general@lists.php.net
>Subject: [PHP] Deleting Objects
>
>
>How does one delete an object? For example:
>
> $object = new Class(...);
> .....
> $object = new Class(...);
>
>I want to throw away the old object and create a new, freshly
>initialized one using the same variable. Is the above
>adequate or will
>this orphan the first object? If so is an unset($object) prior to the
>second "new" the appropriate approach?
>
>Thanks,
>
> ----------
> Tom Rawson
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>