class ClassOne
{
private $foo = null;
public function __construct()
{
$this->foo = new ClassTwo();
}
public function doStuff()
{
$bar = &$this->foo->someVariable;
}
}
Ich weiß, dass $this
bezieht sich auf das aktuelle Objekt, und &
ist ein Referenzsymbol für die ursprüngliche Variable ändern.
Was bedeutet &$this
?
Wenn '$ bar = & $ foo' für Sie sinnvoll ist, warum wäre' $ bar = & $ this' anders? – zzzzBov
Beachten Sie, dass das '&' gilt für alles auf der rechten Seite, also gibt es einen Verweis auf $ this-> foo-> someMethod', nicht '$ this'. – trincot
Was versuchst du zu erreichen? Sie speichern einen Verweis auf '$ this-> foo-> someMethod' in' $ bar' und ich frage mich, was Sie nicht verstehen. – k0pernikus