Javatpoint Logo
Javatpoint Logo

PHP WITH OOPS CONCEPT

Object-oriented programming is a programming model organized around Object rather than the actions and data rather than logic.

Class:

A class is an entity that determines how an object will behave and what the object will contain. In other words, it is a blueprint or a set of instruction to build a specific type of object.

In PHP, declare a class using the class keyword, followed by the name of the class and a set of curly braces ({}).

PHP WITH OOPS CONCEPT

This is the blueprint of the construction work that is class, and the houses and apartments made by this blueprint are the objects.

Syntax to Create Class in PHP

Important note:

In PHP, to see the contents of the class, use var_dump(). The var_dump() function is used to display the structured information (type and value) about one or more variables.

Syntax:

Object:

A class defines an individual instance of the data structure. We define a class once and then make many objects that belong to it. Objects are also known as an instance.

An object is something that can perform a set of related activities.

Syntax:

Example of class and object:

Output:

PHP WITH OOPS CONCEPT

Example 2: Use of var_dump($obj);

Output:

PHP WITH OOPS CONCEPT
Next Topic#




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA