Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
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): bool

Parameters

NameTypeDescription
haystackstringThe string to search in.
needlestringThe 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.