I am new to OOP and I have been working on this example but I cannot seem to get rid of this error
Parse error: syntax error, unexpected ';', expecting T_FUNCTION in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\...\php_late_static_bindings.php on line 16
I was attempting to execute the follow code:
abstract class father {
protected $lastname="";
protected $gender="";
function __construct($sLastName){
$this->lastname = $sLastName;
}
abstract function getFullName();
public static function create($sFirstName,$sLastName){
return new self($sFirstName,$sLastName);
};
}
class boy extends father{
protected $firstname="";
function __construct($sFirstName,$sLastName){
parent::__construct($sLastName);
$this->firstname = $sFirstName;
}
function getFullName(){
return("Mr. ".$this->firstname." ".$this->lastname."<br />");
}
}
class girl extends father{
protected $firstname="";
function __construct($sFirstName,$sLastName){
parent::__construct($sLastName);
$this->firstname = $sFirstName;
}
function getFullName(){
return("Ms. ".$this->firstname." ".$this->lastname."<br />");
}
}
$oBoy = boy::create("John", "Doe");
print($oBoy->getFullName());
Does anyone have any ideas? $oGirl = girl::create("Jane", "Doe"); print($oGirl->getFullName());