Oops Concepts in PHP For Beginners

| Last Updated: | In: PHP Tutorial


Classes Structure

A Class is a blueprint of an object information. It defines the variables and methods that gives a collection of information. For example, lets just see some examples to know the structure of the class :

Create object of class

An Object is a actual thing that create bases of a blueprint (class).

Properties of an object :

  • Identity: the property of an object that distinguishes it from other objects
  • State: describes the data stored in the object
  • Behavior: describes the methods in the object’s interface by which the object can be used

Bellow is the complete code that define a class and and an object.

Copy and paste that code and save as test.php and reloading your browser now you get the outputs the following:

Hello world!

Using of Constructors and Destructors

PHP provides the magic method__construct() which called when you create an object of a class.


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby.


You may also like:


, ,