Oops Concepts in PHP For Beginners

| Last Updated: | In: Core php


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 founder of freewebmentor.com and Software developer from New Delhi (India). Follow Prem's development codes on facebook, and make sure you check out freewebmentor.com for the latest in web development related Tips with the complete code.


You may also like:

Follow us!

Get Free Access of 350+ Scripts

Don't worry you'll not be spammed!

Featured eBook

WordPress Security Guide

Learn how to implement security guideline in your WordPress site...

DOWNLOAD

Pincode Finder

pincode-finder tool

Online Pincode Finder

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

SEARCH NOW