What are anonymous classes in PHP7.

Annie
Written by Annie

Posted On: Jan 09, 2019

 

    1 Answer Written

  •  Annie
    Posted by Burtonkep

    Anonymous Class in PHP is new way of creating object without the need to name them. Anonymous classes are created and initiated at same time.

    Example of an Anonymous Class in PHP

    $object =new class('argument'){
    
    public $property;
    
    public function __construct($argument){
    
    	$this->property=$argument;
    
    }
    
    }
    

Please Login or Register to leave a response.

Related Questions