The reason I used is_int, is because 1.4 is divisible by 2 but according to wiki, it isn't an even number.

Justin Giboney

What about error handling the case where a sting is passed to the function?
This function handles the '3', and the 'your name'

function evenOrOdd ($number) {
    if (is_numeric($number)) {
        $evenOrOdd = 'odd';
        if (($number % 2) == 0)
        {
          $evenOrOdd = 'even';
        }
        print $evenOrOdd."\n";
    }
    else {
        throw new Exception('Argument is invalid, it must be a number');
    }
}


- Kirk

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to