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 8 of 8
function str_ends_with( $haystack, $needle ) { if ( '' === $haystack && '' !== $needle ) { return false; } $len = strlen( $needle ); return 0 === substr_compare( $haystack, $needle, -$len, $len ); }