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


On Wed, Oct 8, 2008 at 3:35 PM, Wade Preston Shearer
<[EMAIL PROTECTED]> wrote:
> On 8 Oct 2008, at 12:54, Justin Giboney wrote:
>
>> I went to a job interview last Thursday in which I felt I did well except
>> for one question that he asked me. He asked me to create a PHP function
>> that
>> takes an input and outputs even if a number is even and odd if a number is
>> odd.* Below are the function that I wrote in the interview, and the
>> function
>> that I would have liked to have written in the interview. Now here are
>> some
>> questions for you:
>
> Are you willing to share what your potential employer thought of your work?
>
>
>
> _______________________________________________
>
> UPHPU mailing list
> [email protected]
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
>

_______________________________________________

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

Reply via email to