Using PHP 5.4 - Company won't upgrade because it would break existing code. Sorry about that.
Say I have a class Resource
:
class Resource {
private $resourceIdentifier;
public function __construct() {
$this->resourceIdentifier = "ResourceId";
}
public function getIdentifier() {
return $this->resourceIdentifier;
}
}
Then, that class has a child:
class Employee extends Resource {
public function __construct() {
$this->resourceIdentifier = "EmployeeId";
}
}
Then I create an instance of employee and call getIdentifier()
$emp = new Employee();
echo $emp->getIdentifier();
Will the function return $resourceIdentifier
from the parent or the child?
On top of that, what will happen if I don't define $resourceIdentifier
in the parent but I do in the child?
class Resource {
public function getIdentifier() {
return $this->resourceIdentifier;
}
}
class Employee extends Resource {
private $resourceIdentifier;
public function __construct() {
$this->resourceIdentifier = "EmployeeId";
}
}