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_ssl_constantsms_file_constantsthe_contentuser_canthe_content_rss
引入
5.9.0
棄用
-

str_contains: 這是一個PHP函式,用於檢查一個字串是否包含另一個字串。它需要兩個引數,$haystack 和 $needle。如果$needle在$haystack中找到,則返回真,否則返回假。

PHP 8.0中新增的`str_contains()’函式的填充。

執行區分大小寫的檢查,表明針是否包含在haystack中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function str_contains( $haystack, $needle ) {
return ( '' === $needle || false !== strpos( $haystack, $needle ) );
}
}
function str_contains( $haystack, $needle ) { return ( '' === $needle || false !== strpos( $haystack, $needle ) ); } }
function str_contains( $haystack, $needle ) {
		return ( '' === $needle || false !== strpos( $haystack, $needle ) );
	}
}

常見問題

FAQs
檢視更多 >