Perchè non stampa Three? Anche se è privata viene richiamata dall'interno di Bar perchè è come scrivere __toString in Bar. Se scrivo esplicitamente il __toString dentro Bar legge anche Three.Originariamente inviato da whisher
tutto regolareCodice PHP:
class Foo {
public function __toString() {
return implode(get_object_vars($this));
}
}
class Bar extends Foo {
public $one = 'One';
protected $two = 'Two';
private $three = 'Three';
}
$b = new Bar();
echo $b;
![]()