← All built-ins / strpos()

strpos()

strpos(...$args): mixed

Parameters

NameTypeDescription
$haystackstringstring to search in
$needlestringstring to search for

Return value

0-based byte position of the first occurrence, or false when not found. Always compare with !== false — position 0 is falsy!

Example

$p = strpos("HolyPHP", "PHP");
echo $p, "
";
var_dump(strpos("HolyPHP", "java") === false);
4
bool(true)

See also

str_contains()strstr()substr()