oop - Why the Functions aren't defined ? PHP -
what have can use standard php functions without creating instance of math_functions class ?
<?php class math_functions { public static function evennumber($number) { return !($number & 1); } public static function natual_sum($n) { while ($n) { if (evennumber($n)) { $sum = $sum + $n; } $n--; } return $sum; } } echo natual_sum(4); ?>
this static function. have access using class name. use this
math_functions::natual_sum(4);
Comments
Post a Comment