Class
Ø A class is defined by using the class keyword, followed by the name of the class and a pair of curly braces ({}). all its properties and methods go inside the braces:
A PHP class is a group of values with a set of operation to manipulate this values.
Ø PHP classes are almost like functions but with a major different that classes contain both variables and function, in a single format called object or can be said Class is made from a collection of objects
Ø class is the blueprint of objects.
Syntax:-
Class classname
{
Variable declaration;
Properties;
function method_name()
{
body of method;
}
function method_name(parameter list)
{
body of method;
}
Example
Class student
{
public $name;
function display ($name)
{
$this->name=$name;
}
}
Rules of Class Declaration
0 Comments