Php Object Oriented Programming

Object Oriented programming is a programming language structure that is associated with the concept of OBJECTS, data fields, method and related member functions. Its to organize the data and structure of an php application.

Now a day without OOP we cannot move a inch in PHP world. All PHP base Framework are established on OOP php language like as – Laravel, CI, Zend.

Basic-OOPSCountless evade the utilization of OOP as a programming worldview, numerous more are seeing the benefits of OOP consistently. Items are setting down deep roots – and on the off chance that you don’t care for them yet, give it a chance: there comes a period in each engineers profession when he makes the transformative stride up to OOP.

OOPS Elements Details:

  1. Class
  2. Object
  3. Inheritance,
  4. Aggregation,
  5. Composition,
  6. Encapsulation
  7. Polymorphism

These are known as fundamentals of Object Oriented Programming.

What and do Class:

It is like structures in C programming. Class can likewise be characterized as defined data type however it additionally contains functions in it. In this way, class is essentially an outline for object. It declare and defines what information/data variables the Object will have and what operations can be performed on the object of class.

Elements of OOPS Class:

==> Object : Objects have states and behaviors.

Objects are the basic element of OOP. Objects areĀ  instances of class, which have data members and uses various member functions to execute their tasks.

Example: A Person has States- color, name, nation and so on. Behaviors – Working, walking, and eating. An object is an instance of a class.

==> Methods – A method is basically a behavior. Class can contain many methods. It is in methods where the logic are written, data is manipulated and all the actions are run.

How to Work OOP Class :

First Create a php file named - myclass.php and keep it into server.

Details Example using Constructor and Function Method :

//Result Display : string(38) “Welcome to Object Oriented Programming”
//string(16) “What is object ?”

Another way to work OOPS Class with Encapsulation

Display Result after Run person.php Code

Mr. XYZ PQR This Person is Young so Far

Working on OOPS Inheritance: