str_contains

函数


str_contains ( $haystack, $needle )
参数
  • (string)
    $haystack
    The string to search in.
    Required:
  • (string)
    $needle
    The substring to search for in the haystack.
    Required:
返回值
  • (bool) True if `$needle` is in `$haystack`, otherwise false.
定义位置
  • wp-includes/compat.php
    , line 440
引入
5.9.0
弃用

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

Performs a case-sensitive check indicating if needle is
contained in haystack.

function str_contains( $haystack, $needle ) {
		return ( '' === $needle || false !== strpos( $haystack, $needle ) );
	}
}