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

Popular posts from this blog

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

ruby on rails - Authlogic - how to make a registration and don't log in the new account? -