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.

Tags: , ,

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:

Get Free Access of 450+ Scripts

Don't worry you'll not be spammed!

Featured eBook

WordPress Security Guide

Free Guide: Learn how to implement security guideline in your WordPress site...


Free WordPress Setup Service

Free WordPress Setup

Want to Setup WordPress Blog Setup? I will help you in the setup of your WordPress blog.

Click Here

Pincode Finder

pincode-finder tool

Online Pincode Finder

Best tool to locate post Office address and pincodes of all india...