<?php class test { function test3() { return rand(0, 5); } function test2($num) { $num2 = $this->test3(); echo $num2 . "<br />"; return $num + $num2; } } $tst = new test(); echo $tst->test2(1); ?>