PHP class
PHP classes help to deal with data in an organized fashion. Every class definition in PHP begins with the keyword “class”. This is followed by the name of the class. Curly braces mark the beginning and end of the class.
Example: $ this is a pseudo variable which is used when a method is called from within an object context. It is a reference to the calling object.
<?php
Class sampleClass
{
//member decklaration
Public $var = ‘some value’;
//method declaration
Public function displayvar()
{
Echo $this -> var;
}
}
?>
Instance of a class can be created by creating a new object and assigning it to a variable. Example: $instance = new sampleClass();