Consider the code below:
<?php
class Base {
protected $name = "Base";
public function getName() {
return $this->name;
}
}
class Foo extends Base {
protected $name = "Foo";
}
$f = new Foo();
echo $f->getName(); // output: Foo
$b = new Base();
echo $b->getName(); // output: Base
Since in other languages such as Java won't allow you to override the instance variable, but it is possible in PHP.
Is it because since PHP is weak type language so it is possible?