Bird
0
0

Which PHP function compares two strings in a case-sensitive manner and returns an integer less than, equal to, or greater than zero?

easy📝 Conceptual Q1 of 15
PHP - String Functions
Which PHP function compares two strings in a case-sensitive manner and returns an integer less than, equal to, or greater than zero?
Astrcmp()
Bstrcasecmp()
Cstrncasecmp()
Dsubstr_compare()
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function purpose

    strcmp() compares two strings exactly, considering case differences.
  2. Step 2: Compare with other functions

    strcasecmp() ignores case, strncasecmp() compares part of strings ignoring case, substr_compare() compares substrings.
  3. Final Answer:

    strcmp() -> Option A
  4. Quick Check:

    Case-sensitive string comparison = strcmp() [OK]
Quick Trick: Use strcmp() for case-sensitive string comparison [OK]
Common Mistakes:
  • Confusing strcmp() with strcasecmp()
  • Using strncasecmp() for full string comparison
  • Assuming substr_compare() compares full strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes