1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php class Foo { private $var1; private $var2; public function Foo($val) { $this->init($val); $this->doSomething(); } private function init($val) { $this->var1 = $val; } private function doSomething() { $this->var2 = sqrt($this->var1); } public function getResult() { return $this->var2; } } ?>