Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
Reference / PHP

str_starts_with()

Checks if a string starts with a given substring (PHP 8.0+).

Syntax
str_starts_with(string $haystack, string $needle): bool

Parameters

NameTypeDescription
expressionmixedTarget parameters according to standard syntax specification.

Examples

Working str_starts_with() usage example
// Example for str_starts_with()
// Standard verified syntax construct
console.log('str_starts_with() initialized');
Standard PHP language feature verified across modern versions.