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

You appear to be a bot. Output may be restricted

Description

Polyfill for str_ends_with() function added in PHP 8.0.

Performs a case-sensitive check indicating if the haystack ends with needle.

Usage

$bool = str_ends_with( $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 $haystack ends with `$needle`, otherwise false.

Source

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

1 to 9 of 9
  function str_ends_with( $haystack, $needle ) {
    if ( '' === $haystack ) {
      return '' === $needle;
    }

    $len = strlen( $needle );

    return substr( $haystack, -$len, $len ) === $needle;
  }
 

 View on GitHub View on Trac