From 8ad5e4cebd5ffe9ca5f11c34b27302166f58764b Mon Sep 17 00:00:00 2001 From: Zankaria Date: Sun, 24 Nov 2024 18:46:26 +0100 Subject: [PATCH] polifill.php: add str_starts_with --- inc/polyfill.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/inc/polyfill.php b/inc/polyfill.php index 2b14c4dc..62976884 100644 --- a/inc/polyfill.php +++ b/inc/polyfill.php @@ -68,12 +68,12 @@ if (!function_exists('imagecreatefrombmp')) { if ($BMP['bits_per_pixel'] == 24) $COLOR = unpack("V",substr($IMG,$P,3).$VIDE); elseif ($BMP['bits_per_pixel'] == 16) - { + { $COLOR = unpack("n",substr($IMG,$P,2)); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 8) - { + { $COLOR = unpack("n",$VIDE.substr($IMG,$P,1)); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } @@ -185,3 +185,12 @@ if (!function_exists('imagebmp')) { return chr($n & 255).chr(($n >> 8) & 255); } } + +// PHP 8.0 + +if (!function_exists('str_starts_with')) { + function str_starts_with(string $haystack, string $needle): bool { + // https://wiki.php.net/rfc/add_str_starts_with_and_ends_with_functions#str_starts_with + return \strncmp($haystack, $needle, \strlen($needle)) === 0; + } +}