As far as Object Orientation is concerned, people don’t regard Php as a suitable language for applying this type of approach. This holds wrong because Object Oriented Programming has more to offer than using the old conventional approach of global variables and functions. First and the foremost thing is the concept of encapsulation.With the help of this approach, we are applying the concepts of data integrity, security, code reusability, redesign and many more.
As we have already covered lots of definitions about classes, objects, constructs in our C# programming section, we will see the examples of using the different ingredients of OOPS with our Php programs. Whenever it is required to highlight the new thing, we will elaborate it.
1. Class, Constructor function, Public Property, Object and Private Variable :
2. Inheritance and Scope Resolution Operator :
3. Abstract Class, multiple Inheritance, Magic Methods:
[Attribute : http://www.php.net/manual/en/keyword.extends.php]
4.Abstract Class with Protected Abstract Methods:
An Abstract class is the one which can not be instantiated therefore we can not make the instance objects from an abstract class.
The abstract methods in the abstract class are the ones that only contain the signatures and they are defined in derived classes from the abstract class.
By using the protected modifier, the methods, variables, fields can only be accessed in the derived classes of the base class.
5. Auto loading classes
With the help of auto-load, we can load already created classes in our programs.Below are the examples.
Refer the topic in C# for the definition of interfaces and their role and importance in OOPS