December 2001
Intermediate to advanced
520 pages
13h 42m
English
True object-oriented programming languages include the ability to destroy an instance of an object using destructors, the opposite of a constructor. Whereas a constructor is immediately called upon creation of an object, a destructor would be automatically called when an object is destroyed. PHP does not have this capability built-in, but you can replicate it to a degree.
Should you want to free up the resources used by an object that's no longer necessary, start by deleting the value of the instance using the unset() function.
$object = new ClassName; unset ($object);
As a simple example of destroying an object, I'll modify the instance5.php script.
1. |
Open instance5.php (Script 2.14) in your text ... |
Read now
Unlock full access