Bird
0
0

What is the output of this PHP code?

medium📝 Predict Output Q5 of 15
PHP - Variables and Data Types
What is the output of this PHP code?
$num = -5;
echo abs($num);
A-5
B0
C5
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand abs() function in PHP

    abs() returns the absolute value (positive) of a number.
  2. Step 2: Apply abs() to -5

    abs(-5) returns 5, the positive value.
  3. Final Answer:

    5 -> Option C
  4. Quick Check:

    abs() returns positive value = 5 [OK]
Quick Trick: abs() returns positive value of any number. [OK]
Common Mistakes:
  • Expecting abs() to return negative number
  • Confusing abs() with negation
  • Thinking abs() causes errors on negatives

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes