PHP class

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();
PHP inheritance
Inheritance is a mechanism that extends and existing class.
PHP overriding methods
PHP overriding methods
PHP objects & properties
Every class in PHP must have new instances or object created. This object must be assigned to a variable.
Post your comment
Discussion Board
php_class
simple and short easy to understand - thank you.
Md.fareeduddin 09-8-2015