Перейти на php8, больше никакой функции money_format()

Php8 говорит: Неустранимая ошибка: Неперехваченная ошибка: вызов неопределенной функции money_format()

страница php.net

      money_format
(PHP 4 >= 4.3.0, PHP 5, PHP 7)

money_format — Formats a number as a currency string

Warning
This function has been DEPRECATED as of PHP 7.4.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.

Как лучше всего обновить money_format () в php8?

1 ответ

Вы должны использовать NumberFormatter класс доступен с php 5.3

пример:

        $amount = 12932.203;
  $formtater = new \NumberFormatter( 'en_US', \NumberFormatter::CURRENCY);
  var_dump($formtater->format($amount));

выход:

       $12,932.20

ссылка

Другие вопросы по тегам