str_starts_with( string $haystack, string $needle )
Polyfill for str_starts_with()
function added in PHP 8.0.
Description
Performs a case-sensitive check indicating if the haystack begins with needle.
Parameters
- $haystack
-
(string) (Required) The string to search in.
- $needle
-
(string) (Required) The substring to search for in the
$haystack
.
Return
(bool) True if $haystack
starts with $needle
, otherwise false.
Source
File: wp-includes/compat.php
function str_starts_with( $haystack, $needle ) { if ( '' === $needle ) { return true; } return 0 === strpos( $haystack, $needle ); }
Expand full source code Collapse full source code View on Trac View on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |