I see and use this syntax alot in Laravel, I wonder how it works, cause I try to integrate it in my own project but I get errors like this
FATAL ERROR Uncaught TypeError: Argument 1 passed to getVal() must be an instance of Man, none given, called in'
now here is Laravel type code as you all know
public function join(Request $request){
echo $request['name'];
//for instance
}
and it works fine, now here is my code:
class Man {
public $child,
$wife;
public function _construct(){
$this->child = 1;
$this->wife = 2;
}
}
function getVal(Man $man){
echo $man->wife;
}
getVal();
Please help me understand this better.