mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-03 08:22:24 +02:00
fixes #2458 add polyfill for str_starts_with function
Introduces a compatibility implementation of str_starts_with for environments where it is not available. Updates common.inc.php to include the polyfill if the function does not exist.
This commit is contained in:
@@ -66,7 +66,8 @@ $filter = array();
|
|||||||
|
|
||||||
foreach(
|
foreach(
|
||||||
array(
|
array(
|
||||||
'gzopen'
|
'gzopen',
|
||||||
|
'str_starts_with'
|
||||||
) as $func)
|
) as $func)
|
||||||
{
|
{
|
||||||
if (!function_exists($func))
|
if (!function_exists($func))
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
if (!function_exists('str_starts_with'))
|
||||||
|
{
|
||||||
|
function str_starts_with(string $haystack, string $needle): bool
|
||||||
|
{
|
||||||
|
return strlen($needle) === 0 || strpos($haystack, $needle) === 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user