1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php class Base { public function __toString() { return $this->name; } } class Concrete extends Base { private $name; public function __construct($name) { $this->name = $name; } } $o = new Concrete('foobar'); echo $o;
1 2
Fatal error: Cannot access private property Concrete::$name on line 5