← All built-ins / str_starts_with()
str_starts_with()
str_starts_with(string $haystack, string $needle): bool
Parameters
| Name | Type | Description |
|---|---|---|
| $haystack | string | string to test |
| $needle | string | required prefix |
Return value
true when $haystack begins with $needle.
Example
var_dump(str_starts_with("holy.php", "holy"));
var_dump(str_starts_with("holy.php", ".php"));bool(true) bool(false)