mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Fix some minor bugs in global functions and add unit tests
This commit is contained in:
parent
c64df413f5
commit
f9ea115c19
2 changed files with 158 additions and 3 deletions
|
|
@ -238,7 +238,7 @@ function starts_with($needle, $haystack, $case_sensitive = true)
|
|||
}
|
||||
else
|
||||
{
|
||||
!strncasecmp($needle, $haystack, strlen($needle));
|
||||
return !strncasecmp($needle, $haystack, strlen($needle));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -452,8 +452,11 @@ if (!function_exists('hex2bin'))
|
|||
*/
|
||||
function tobool($input)
|
||||
{
|
||||
if (preg_match('/^(1|[ty].*|on|oui|si|vrai|aye)$/i', $input)) return true;
|
||||
if (preg_match('/^(0|[fn].*|off)$/i', $input)) return false;
|
||||
if (is_scalar($input))
|
||||
{
|
||||
if (preg_match('/^(1|[ty].*|on|ok.*oui|si|vrai|aye)$/i', $input)) return true;
|
||||
if (preg_match('/^(0|[fn].*|off)$/i', $input)) return false;
|
||||
}
|
||||
return (bool)$input;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue