-2

Do both the function return the same value?

<?php
echo "<br>".strstr("this is a test", "s");
echo "<br>".strchr("this is a test", "s");
?>

Is there any difference that i can't see?

Aditya Thakur
  • 125
  • 1
  • 2
  • 12

2 Answers2

0

strstr

strstr — Find the first occurrence of a string

PHP manual link for strstr

strchr

This function is an alias of: strstr().

PHP manual link for strchr

So, for your Question, the answer is "BOTH ARE SAME"

masterFly
  • 1,072
  • 12
  • 24
  • They are not "both the same". Not being pedantic, but specifically the end result is the same, but they are not to be considered the same from a dev POV as the alias may go away after deprecation period. – James Sep 09 '20 at 13:21
-1

You used strstr() which is an alias of strchr(), that's why it is just the same. But your reference compares strchr() and strrchr(), that's why you get a different result than from your reference

EDIT

Since you've edited your question. This is now my answer:

You used strstr() which is just an alias of strchr(), that's why it is just the same.

Carl Binalla
  • 5,393
  • 5
  • 27
  • 46