Bird
0
0

Which of the following is the correct syntax to find the position of 'dog' in the string $text using strpos?

easy📝 Syntax Q3 of 15
PHP - String Functions
Which of the following is the correct syntax to find the position of 'dog' in the string $text using strpos?
Astrpos('dog', $text);
Bstrpos($text, 'dog');
Cstrpos($text);
Dstrpos('dog');
Step-by-Step Solution
Solution:
  1. Step 1: Recall strpos parameter order

    The first parameter is the string to search in, the second is the substring to find.
  2. Step 2: Match correct syntax

    strpos($text, 'dog'); correctly uses strpos($text, 'dog'). Other options have wrong parameter order or missing parameters.
  3. Final Answer:

    strpos($text, 'dog'); -> Option B
  4. Quick Check:

    Correct parameter order = D [OK]
Quick Trick: First argument is full string, second is substring [OK]
Common Mistakes:
  • Swapping parameters order
  • Missing second parameter
  • Passing substring first

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes