str_contains( string $haystack, string $needle )

Polyfill for str_contains() function added in PHP 8.0.


Description

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


Parameters

$haystack

(Required) The string to search in.

$needle

(Required) The substring to search for in the haystack.


Return

(bool) True if $needle is in $haystack, otherwise false.


Source

File: wp-includes/compat.php

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


Changelog

Changelog
Version Description
5.9.0 Introduced.