wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



str_contains › WordPress Function

Desde5.9.0
Obsoleton/a
str_contains ( $haystack, $needle )
Parâmetros: (2)
  • (string) $haystack The string to search in.
    Required: Yes
  • (string) $needle The substring to search for in the `$haystack`.
    Required: Yes
Retorna:
  • (bool) True if `$needle` is in `$haystack`, otherwise false.
Definido em:
Codex:

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

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


Fonte

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

		return false !== strpos( $haystack, $needle );
	}
}