For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > May 2006 > #36971 [Com]: unset() no longer works on $this in PHP5









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #36971 [Com]: unset() no longer works on $this in PHP5
gixxman at gmali dot com

2006-05-04, 7:58 am

ID: 36971
Comment by: gixxman at gmali dot com
Reported By: k at phpkoala dot com
Status: Open
Bug Type: Documentation problem
Operating System: Linux
PHP Version: 5.1.2
New Comment:

class FalseClass
{
public function __destruct()
{
echo "Gonna die, man";
}
}

$f = new FalseClass;
unset($f);


RESULTS:

Gonna die, man


Previous Comments:
------------------------------------------------------------------------

[2006-04-05 19:04:17] k at phpkoala dot com

Thanks Scott, that makes sense.

Does that mean there is no way to accomplish this in PHP5? I guess so.

I'd like to see this added to the docs.

------------------------------------------------------------------------

[2006-04-05 06:21:38] derick@php.net

@Scott: totally true.

This can ofcourse be mentioned in the documentation if it's not already
there...

------------------------------------------------------------------------

[2006-04-04 23:53:40] scottmacvicar at ntlworld dot com

Destroying an object internally is an absurd concept, how can you
destroy something that is currently in the scope of execution?

The reason it works in PHP 4 and not in PHP 5 is that object types are
no longer mutable.

------------------------------------------------------------------------

[2006-04-04 23:18:38] k at phpkoala dot com

Mike, I am serious or I would not have taken the time to post this bug
report.

The manual page for unset, over at
http://www.php.net/manual/en/function.unset.php, does not mention this
change in functionality. Like I said in my first message, this is
something that works in PHP4 but no longer works in PHP5.

If you can't believe I am serious, please point out why you think this
is a joke? How do you destroy a class instance internally in PHP5? And
if this is never going to happen, can't you say this in the manual,
along with an explanation?

If nothing else, the very fact that it worked in PHP4 and does not work
in PHP5 should merit a mention in the documentation. (Just Google for
this issue and you will see many pieces of software that have broken
because of this, when used on PHP5.)

Back to you, Mike.

------------------------------------------------------------------------

[2006-04-04 19:33:07] mike@php.net

I can't believe you're serious.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/36971

--
Edit this bug report at http://bugs.php.net/?id=36971&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com