logo CodeStepByStep logo


Language/Type: PHP parameters boolean
Author: Mariana Stepp (added by Melissa Hovik on 2018/01/05)

Write a function named is_multiple that accepts two non-negative parameters $a and $b, and returns true if $a is a multiple of $b, and false otherwise.

For example, the call of is_multiple(15, 5) would return true because 15 = 5 * 3. If either $a or $b are negative integers, or $b is 0, your function should throw an Exception with the message, "Error: both arguments must be non-negative, and b must not be 0."

You may assume that both parameters passed are Integer types.

Function: Write a PHP function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.