PDA

View Full Version : What is the difference between the functions strstr() and stristr()?



seo.gops
08-25-2021, 03:15 PM
What is the difference between the functions strstr() and stristr()?

Shree Vaghani
09-13-2021, 02:38 AM
strstr() and stristr both are used to find the first occurrence of the string.

In PHP both functions are used to find the first occurrence of a substring in a string except
stristr() is case-insensitive and strstr is case-sensitive, if no match is found then FALSE will be returned.

Sample Usage:

<?php
$email = ‘abc@xyz.com’;
$hostname = strstr($email, ‘@’);
echo $hostname;
output: @xyz.com
?>
stristr() does the same thing in Case-insensitive manner.