canFly = $canFly; if ($canWalk) { $this->legCount = $legCount; } } public function getLegCount(){ return $this->legCount; } } $b1 = new bird(true, true, 3); // $this->legCount created here $b2 = new bird(true, false, 3); // $this->legCount NOT created here echo $b1->getLegCount() . "\n"; echo $b2->getLegCount() . "\n";