Reference / PHP
str_contains()
Performs a case-sensitive check indicating if needle is contained in haystack (PHP 8.0+).
Syntax
str_contains(string $haystack, string $needle): boolParameters
| Name | Type | Description |
|---|---|---|
| haystack | string | The string to search in. |
| needle | string | The substring to search for. |
Examples
Checking domain
if (str_contains('admin@syntaxis.local', '@syntaxis')) {
echo 'Syntaxis domain detected';
}Returns true if needle is an empty string.