Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP Fatal error: Constructor test::test() cannot declare a return type in /home/iBMCb9/prog.php on line 6

// in php you must declare __construct method and
//then use void for all methods that you want.
class Test{
    public $name = "mohamad";  
    public function __construct(){}

    public function test():void {
      
    }
}

$obj = new Test();
echo $obj->test();
echo $obj->name;
 
PREVIOUS NEXT
Tagged: #PHP #Fatal #Constructor #declare #return #type #line
ADD COMMENT
Topic
Name
3+9 =