I'm new at OOP programming. So I have 2 Questions about the __destruct function.
Can I call another object-function from __destruct or are the other functions already undeclarated? For example:
function __destruct()
$this->save();
Can I also call the __destruct function in my normal code? For example:
$object_name->__destruct();
Yes, that would work I guess, although invoking a save() call inside a garbage collector would be kind of counterintuitive (and terrible design.)
Yes, if you want, or it will be invoked automagically by PHP when no more references to the object exist.
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