Üst sınıf değişkeni

0 Cevap php

İşte benim temel bir örnek:

class Foo {

    public $toy = "car";

    public function run() {
        $this->toy = "train";
        $bar = new Bar();
        $bar->run();
    }   
}

class Bar extends Foo {
    public function run() {
        echo $this->toy;
    }
}

$foo = new Foo();
$foo->run();

Nedense her zaman yankı araba tren olmaz. Bunun sebebi nedir?

0 Cevap