PHP str_contains() Function Last Updated : 09 Sep, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The str_contains() is a predefined function that is introduced with the release of PHP 8. The str_contains() function search for the substring in the given string within the expression. If the substring mentioned will be present in the string then it will return True otherwise it will return False. The str_contains() function is very similar to strpos() function. Properties: It always returns a boolean value.It will return TRUE in case of checking for the substring as empty.It is case-sensitive.This function is binary-safe.It is only supported on PHP 8 or higher versions.Syntax:(str_contains('String', 'Substring')) ; A substring is a string that needs to be searched whereas a string is a part where a substring is to be searched. Note: str_contains() is only supported in PHP 8 or higher versions.Example: In the below example, we have a sentence stored in $sentence and a word stored in $word. In this example, we are trying to check whether the word is present in the sentence or not by using the str_contains() function. If the word will be present in the sentence 'is' will be assigned to $result otherwise its value will be 'is not'. We will understand this using example. PHP <?php $sentence = 'GFG is Awesome'; $word = 'GFG'; $result = str_contains($sentence, $word) ? 'is' : 'is not'; echo "The word {$word} {$result} present in the sentence \"{$sentence}\" "; ?> From the above, we have seen how to find the substring in a given string by using the str_contains() function & the return value will be the boolean. Output:The word GFG is present in the sentence "GFG is Awesome" Reference: https://www.php.net/manual/en/function.str-contains.php Comment More infoAdvertise with us Next Article PHPUnit | assertContains() function T talktoosaurabh Follow Improve Article Tags : Web Technologies PHP PHP-string PHP-function Similar Reads PHP substr_count() Function The substr_count() is a built-in function in PHP and is used to count the number of times a substring occurs in a given string. The function also provides us with an option to search for the given substring in a given range of the index. It is case sensitive, i.e., "abc" substring is not present in 3 min read PHP | DsSet contains() Function The Ds\Set::contains() function is an inbuilt function in PHP which is used to check the given value exists in the set or not. This function compares the value and its type. Syntax: bool public Ds\Set::contains( $values ) Parameters: This function accepts a single or many values which need to check 1 min read PHP SplObjectStorage contains() Function The SplObjectStorage::contains() function is an inbuilt function in PHP which is used to check the storage object contains a specified object or not. Syntax: bool SplObjectStorage::contains( $value ) Parameters: This function accepts a single parameter $value which specifies the storage object which 1 min read PHPUnit | assertContains() function The assertContains() function is a builtin function in PHPUnit and is used to assert an array having a value. This assertion will return true in the case if the array contains the provided value else return false and in case of true the asserted test case got passed else test case got failed. Syntax 2 min read PHP mb_substr_count() Function The  mb_substr_count() function is an inbuilt function in PHP that counts the occurrence of strings within a given string. Syntax: mb_substr_count($haystack, $needle, $encoding): intParameters: This function accepts three parameters that are described below: $haystack: This is the main parameter wh 1 min read PHP | DsDeque contains() Function The Ds\Deque::contains() function is an inbuilt function in PHP which is used to check the deque contains given values or not. Syntax: bool Ds\Deque::contains( $values ) Parameters: This function accepts single or many $values which hold the value to check that value exist in the deque or not. Retur 1 min read Like