Zitat:
Zitat von SanPedro
macht man das so?
|
Nein, weil die Variable $adresse zum lokalen Variablenscope der Methode zählen wurde und weg wäre, wenn die Methode beendet wird.
PHP-Code:
class A {
private $foo;
public function __construct(){
$this->foo = 'bar';
}
public function __get($name){
return $this->foo;
}
}
class B {
protected static $fremde_klasse = null;
public function __construct(){
self::$fremde_klasse = new A;
}
function geht_fremd(){
echo self::$fremde_klasse->foo;
}
}
So oder so ähnlich...