sum = 0; } public function one() { $a = 5; $this->sum = $this->sum + $a; return $this; } public function two() { $a = 6; $this->sum = $this->sum + $a; return $this; } public function display() { print $this->sum; } } $blah = new Blah(); $blah->one()->two()->one()->two()->one()->display();