Class is a user-defined datatype that contains variables, properties, and methods. It defines properties of an Object

Example

                                        

class Person{

    public $name;

    function __construct($name){

        $this->name = $name;

    }

    function getUserDetails(){

        return "My name is ".$this->name;

    }

}

Suggest An Answer

Our Particitants

class Person{ public $name; function __construct($name){ $this->name = $name; } function getUserDetails(){ return "My name is ".$this->name; } } $obj = new Person('Naresh'); echo $obj->getUserDetails();