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();
Since in other languages, such as Java, you cannot override the instance variable, but this is possible in PHP.
Is this because PHP is a weak type, so is that possible?
java oop php instance-variables
Howard
source share