Bird
0
0

Identify the error in this PHP code snippet:

medium📝 Debug Q6 of 15
PHP - String Functions
Identify the error in this PHP code snippet:
$result = strncmp('Test', 'test');
echo $result;
ANo error, code runs fine
BUsing strncmp() instead of strcmp()
CIncorrect variable names
DMissing third parameter for length in strncmp()
Step-by-Step Solution
Solution:
  1. Step 1: Check strncmp() function signature

    strncmp() requires three parameters: two strings and length to compare.
  2. Step 2: Identify missing parameter

    Code only passes two parameters, missing length argument.
  3. Final Answer:

    Missing third parameter for length in strncmp() -> Option D
  4. Quick Check:

    strncmp() needs length parameter [OK]
Quick Trick: strncmp() requires length parameter as third argument [OK]
Common Mistakes:
  • Omitting length parameter in strncmp()
  • Confusing strncmp() with strcmp()
  • Assuming default length

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes