What is the main purpose of a destructor in a PHP class?
- To perform cleanup tasks and deallocate resources
- To initialize the object properties
- To define class constants
- To call other methods within the class
The main purpose of a destructor in a PHP class is to perform cleanup tasks and deallocate resources held by the object. The correct option is "To perform cleanup tasks and deallocate resources." The destructor is automatically called when an object is no longer referenced or explicitly destroyed, allowing you to release any resources or perform necessary cleanup operations. For more information, consult the PHP documentation on destructors: https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.destruct
Loading...