Bird
0
0

Find the issue in this PHP code snippet:

medium📝 Debug Q7 of 15
PHP - Output and String Handling
Find the issue in this PHP code snippet:
echo sprintf("%10s", "hello", "world");
AInvalid format specifier %10s
BToo few arguments for format specifiers
CExtra argument ignored, no error
DSyntax error due to multiple arguments
Step-by-Step Solution
Solution:
  1. Step 1: Check format specifiers and arguments

    There is one specifier %10s and two arguments "hello" and "world".
  2. Step 2: Understand behavior with extra arguments

    Extra arguments are ignored; no error occurs, only first argument used.
  3. Final Answer:

    Extra argument ignored, no error -> Option C
  4. Quick Check:

    Extra arguments after specifiers are ignored [OK]
Quick Trick: Extra arguments after specifiers are ignored silently [OK]
Common Mistakes:
  • Expecting error on extra arguments
  • Confusing argument count rules
  • Misreading format specifier width

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes