August 2003
Intermediate to advanced
1104 pages
19h 27m
English
If you choose to declare a function within a class named __construct, the function will be considered a constructor and will be executed immediately upon creating an object from that class. To be clear, the first two characters are underscores. Like any other function, the constructor may have parameters and even default values. You can set up classes that allow you to create an object and set all its properties in one statement. You may also define a method named __destruct. PHP calls this method when it destroys the object. It's called a destructor.
One powerful aspect of classes is inheritance, the idea that a class can extend the functionality of another class. The new class will contain all the methods and ...
Read now
Unlock full access