Bird
0
0

What is the output of the following PHP code?

medium📝 Debug Q6 of 15
PHP - Variables and Data Types
What is the output of the following PHP code?
$num = 08;
echo $num;
AParse error due to invalid octal number
B8
C0
DNULL
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP integer literals

    In PHP, numbers starting with 0 are interpreted as octal (base 8).
  2. Step 2: Check the given number

    The number 08 is invalid in octal because 8 is not a valid octal digit (digits must be 0-7).
  3. Step 3: Result

    PHP throws a parse error when encountering invalid octal literals like 08.
  4. Final Answer:

    Parse error due to invalid octal number -> Option A
  5. Quick Check:

    Leading zero means octal; 8 is invalid digit [OK]
Quick Trick: Numbers starting with 0 are octal; 8 is invalid digit [OK]
Common Mistakes:
  • Assuming 08 is a decimal number
  • Expecting output '8' without error
  • Confusing octal and decimal literals

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes