I came across one class and what cought my attention right away was this:
public function __destruct() {
unset($this);
}
My first thought was that this is just plain stupidity, it fact it looked so idiotic that I thought that either there really is a good reason to do this or the author is just clueless
Any thoughts? Any reasons to do this?
Short answer: No
Long answer: Noooooooooooooooooooooo
My first thought was that this is just plain stupidity, it fact it looked so idiotic that I thought that either there really is a good reason to do this or the author is just clueless.
The latter, I'm afraid: there is no point in unsetting an instance on destruct. It might be the original programmer is a big fan of being explicit, but the worst thing is that this doesn't even work:
<?php
class Foo {
function __destruct( ) {
unset( $this );
}
}
$foo = new Foo;
$foo->__destruct( );
var_dump( $foo );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With