me

Creating a class in PHP

With the release of  its fifth version PHP has become a multi paradigm language(well, mostly) providing extensive object oriented support. I have been trying my hands on some of the new oo features in PHP.

Defining a class

A class provides a blue print for objects. It is, in simple terms, much like a datatype.  It contains properties and methods. Properties are the variables linked to a class and Methods are the functions.

A class is created by the following code

class Myclass
{
// properties
// methods
}

Thats it!

This class contains nothing but some comments. It wont do anything but all that is being done by us is defining the class.

Leave a Reply