Changeset 57442 for branches/4.4
- Timestamp:
- 01/30/2024 05:27:44 PM (10 months ago)
- Location:
- branches/4.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4
- Property svn:mergeinfo changed
/trunk merged: 52040,56015-56016
- Property svn:mergeinfo changed
-
branches/4.4/src/wp-includes/compat.php
r34981 r57442 338 338 require ABSPATH . WPINC . '/random_compat/random.php'; 339 339 } 340 341 if ( ! function_exists( 'str_starts_with' ) ) { 342 /** 343 * Polyfill for `str_starts_with()` function added in PHP 8.0. 344 * 345 * Performs a case-sensitive check indicating if 346 * the haystack begins with needle. 347 * 348 * @since 5.9.0 349 * 350 * @param string $haystack The string to search in. 351 * @param string $needle The substring to search for in the `$haystack`. 352 * @return bool True if `$haystack` starts with `$needle`, otherwise false. 353 */ 354 function str_starts_with( $haystack, $needle ) { 355 if ( '' === $needle ) { 356 return true; 357 } 358 359 return 0 === strpos( $haystack, $needle ); 360 } 361 } 362 363 if ( ! function_exists( 'str_ends_with' ) ) { 364 /** 365 * Polyfill for `str_ends_with()` function added in PHP 8.0. 366 * 367 * Performs a case-sensitive check indicating if 368 * the haystack ends with needle. 369 * 370 * @since 5.9.0 371 * 372 * @param string $haystack The string to search in. 373 * @param string $needle The substring to search for in the `$haystack`. 374 * @return bool True if `$haystack` ends with `$needle`, otherwise false. 375 */ 376 function str_ends_with( $haystack, $needle ) { 377 if ( '' === $haystack ) { 378 return '' === $needle; 379 } 380 381 $len = strlen( $needle ); 382 383 return substr( $haystack, -$len, $len ) === $needle; 384 } 385 }
Note: See TracChangeset
for help on using the changeset viewer.