wpseek.com
WordPress开发者和主题制作者的搜索引擎



str_starts_with › WordPress Function

Since5.9.0
已弃用n/a
str_starts_with ( $haystack, $needle )
参数: (2)
  • (string) $haystack The string to search in.
    Required: Yes
  • (string) $needle The substring to search for in the `$haystack`.
    Required: Yes
返回:
  • (bool) True if `$haystack` starts with `$needle`, otherwise false.
定义在:
文档:

Polyfill for `str_starts_with()` function added in PHP 8.0.

Performs a case-sensitive check indicating if the haystack begins with needle.


源码

function str_starts_with( $haystack, $needle ) {
		if ( '' === $needle ) {
			return true;
		}

		return 0 === strpos( $haystack, $needle );
	}
}