Skip to content

PHP 8: str_contains function

It checks if the given substring contains a given string. If the substring mentioned will be present in the string then it will return True otherwise it will return False.

if(str_contains("abc", "a")) { 
  echo 'Found';

str_contains("abc", "d"); // false

str_contains() function is case-sensitive. There is no case-insensitive variant of this function.

str_contains() function always returns a boolean value.

str_contains() function will return TRUE in case of checking for the substring ("") as empty.


str_contains('Foo', ''); // true
str_contains('', ''); // true
0 0 votes
Article Rating
Notify of

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments