Class in OOP PHP ?

This tutorial, we will start from the basic concept of classes . Class is something which defines your object. Class represents all properties and behaviors of object. Now let us take an example of the programming. Your interest calculator object is instance of class interest calculator. Interest calculator class defines properties like capital rate, and behavior like simple interest calculation and compound interest calculation.
In PHP creation of class is very simple. You can create class using tag class.  In class block you can define your properties as class variable and function as class behavior. Classes and Objects are key part of object oriented programming


class MyClass 
        public $var;

    // Class constructor
    public function __construct($var)
        echo 'Created an object of MyClass';
        $this->var = $var;

    public function show_var()
        echo $this->var;
// Make an object
$objA = new MyClass('A');

// Call an object method to show the object's property

// Make another object and do the same
$objB = new MyClass('B');

Read more OOP in PHP