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

You appear to be a bot. Output may be restricted

Description

Polyfill for str_contains() function added in PHP 8.0.

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

Usage

$bool = str_contains( $haystack, $needle );

Parameters

$haystack
( string ) required – The string to search in.
$needle
( string ) required – The substring to search for in the haystack.

Returns

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

Source

File name: wordpress/wp-includes/compat.php


Lines:

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

 View on GitHub View on Trac