After taking a look at some old code:
//Nothing like a destructor!!
function destroy() {
settype(&$this, 'null');
}
And called by
$Cache->destroy();
However in PHP 5.3 I get
Deprecated: Call-time pass-by-reference has been deprecated in /blah/-cache-.php on line 154
How should I do this?
Your immediate problem can be met by removing the
&in$this, but the whole construction doesn’t make sense to me. If it’s not plain invalid to destroy$thisfrom within the object’s context, it’s definitely not good practice.To destroy an object, a simple
will do.
If one wants to execute stuff when the object is destroyed, one should define a destructor in the class. (The comment in your
destroy()code says that this is not the point here, though. 🙂