Lokang 

PHP and MySQL

Constructor

Constructor runs the process of calling access modifiers. It is a function in PHP which is name __constructor. For this example, we an access modifier private and the methods name(). The constructor has a double underscore mark. It is then echoed the name of the function to output ‘Lokang’.

 

<?php
class Constructor{
    private $name = 'Lokang';
    public function __constructor($name){
        $this->age = $age;
    }

    public function name(){
        return $this->name;
    }
}

$constructor = new Constructor();
echo $constructor->name();