Deleting objects

So far our objects have been automatically destroyed at the end of the script they were created in, thanks to PHP's automatic garbage collection. However, you will almost certainly want to arbitrarily delete objects at some point in time, and this is accomplished using unset() in the same way as you would delete an ordinary variable.

Calling unset() on an object will call its destructor before deleting the object, as you would expect.


Next chapter: Copying objects >>

Previous chapter: Destructors

Jump to:


Home: Table of Contents

Follow us on or Twitter

Username:   Password:
Create Account | About TuxRadar