Multiple choice technology

What does this function do:

  1. tests whether $variable is a number and ends in 2
  2. tests whether $variable ends in 2
  3. tests whether $variable is a number and contains 2
  4. tests whether $variable is an even number
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The function uses is_numeric to verify the input is a number, then checks if $variable % 2 == 0. The modulo operator (%) returns the remainder when divided by 2; for even numbers this remainder is 0. Therefore this function tests whether $variable is an even number.