str_starts_with

函数
str_starts_with ( $haystack, $needle )
参数
  • (string) $haystack The string to search in.
    Required:
  • (string) $needle The substring to search for in the `$haystack`.
    Required:
返回值
  • (bool) True if `$haystack` starts with `$needle`, otherwise false.
定义位置
相关方法
str_ends_withtimer_startstart_wp_post_statesrest_get_date_with_gmt
引入
5.9.0
弃用
-

str_starts_with: 这是一个PHP函数,用于检查一个字符串是否以另一个字符串开始。它需要两个参数,$haystack 和 $needle。如果$haystack以$needle开头,则返回true,否则返回false。

PHP 8.0中添加的`str_starts_with()’函数的多元填充。

执行区分大小写的检查,表明干草堆是否以 needle 开头。

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

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

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 18:32:58

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: