0
Destructor + unset
There is a remark "To explicitly trigger the destructor, you can destroy the object using the unset() function in a statement similar to: unset($p);" 1) How is it connected with the destructor? 2) Should we use __destruct + unset? 3) Why don't people put unset function inside the constructor?
1 Resposta
0
We can set values and functions, with constructor when an object created...
and sometimes we need to do something on unset an object, like disconnect database connection, So we use destructor.
1 & 2) destructor run when we unset($object);
3) because it is not Standard! I wrote that top👆...