Fixed: [Deprecated] number_format(): Passing null to parameter (#729)

This commit is contained in:
Roman Kelesidis 2023-05-29 01:18:13 +07:00 committed by GitHub
commit 0c5f584bbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 12 deletions

View file

@ -360,6 +360,8 @@ function prn_r($var, $title = '', $print = true)
}
/**
* Convert special characters to HTML entities
*
* @param $txt
* @param bool $double_encode
* @param int $quote_style
@ -371,6 +373,20 @@ function htmlCHR($txt, bool $double_encode = false, int $quote_style = ENT_QUOTE
return (string)htmlspecialchars($txt ?? '', $quote_style, $charset, $double_encode);
}
/**
* Adds commas between every group of thousands
*
* @param float|null $num
* @param int $decimals
* @param string|null $decimal_separator
* @param string|null $thousands_separator
* @return string
*/
function commify(?float $num, int $decimals = 0, ?string $decimal_separator = '.', ?string $thousands_separator = ','): string
{
return number_format($num ?? 0.0, $decimals, $decimal_separator, $thousands_separator);
}
/**
* @param $txt
* @param int $quote_style