I wrote this little test script for PHP object inheritance :
<?php
class A {
protected $attr;
public function __construct($attr) {
$this->$attr = $attr;
}
public function getAttr() {
return $this->attr;
}
}
class B extends A {
}
$b = new B(5);
echo $b->getAttr();
This displays nothing!
Why doesn't it display 5?
Isn't class B supposed to be like class A?