Tag: create a class in php

How can we create a class in php?

December 26, 2009 | Filed Under Oops | Leave a Comment

Classes are the type of objects.

The class is the type of the object,and the object is an instance of the class.You normally create objects using classes,and then use those objects in your code.

Example:–
class Harry
{
var $name;
function set_name($data)
{
global $name;
$name = $data;
}
function get_name()
{
global $name;
return $name;
}
}
In php,classes are usually given names that start whit a capital letter,and objects are given names that start with a lowercase letter.

Article written by urooj

© PHPInterviewQuestion.com 2009 - 2010

eXTReMe Tracker