That will work perfectly.
[EMAIL PROTECTED] wrote:
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
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.
Not exactly true. unset() destroys the reference to the value, not the
value itself. For instance,
error_reporting(E_ALL);
$var1 = foo;
$var2 = $var1;
print $var1\n$var2\n\n;
unset($var1);
print $var1\n$var2;
will output:
foo
foo
br /
bNotice/b: Undefined variable: var1 in bPHPDocument1/b
: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] Deleting Objects
Not exactly true. unset() destroys the reference to the value, not the
value itself. For instance,
error_reporting(E_ALL);
$var1 = foo;
$var2 = $var1;
print $var1\n$var2\n\n;
unset($var1);
print $var1\n$var2;
will output
4 matches
Mail list logo