Object Oriented Programming with Php




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.

[Attribute:http://www.php.net/manual/en/language.oop5.abstract.php]

5. Auto loading classes

With the help of auto-load, we can load already created classes in our programs.Below are the examples.

5. Interfaces

Refer the topic in C# for the definition of interfaces and their role and importance in OOPS


Syed Adeel Ahmed
Syed Adeel Ahmed
Analyst, Programmer, Educationist and Blogger at Technofranchise
Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Published by

Syed Adeel Ahmed

Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.