Call to undefined function money_format ()


I'm doing my project in php version 7.1.8 in laravel framework but I get this error when I use Call to undefined function App \ Http \ Controllers \ money_format () can someone help me?

asked by Lioni_Lee 16.09.2018 в 02:13

1 answer


money_format does not work on some systems. For example, if you are testing the code in Windows, it will give you the error Undefined . The PHP Manual says in a note :


The money_format() function is only defined if the system has   capacity strfmon . For example, Windows does not do it, so    money_format() is not defined in Windows.

In the contribution notes of the same Manual there is a function by Rafael M. Salvioni that you can implement, as it works on Windows.

Or you can opt for a simpler implementation, depending on what you want to do. For example, in this SO answer in English show a simple way to format dollars:

function asDollars($value) {
  return '$' . number_format($value, 2);

With these two starting points, you will be able to face the problem with your own function, adapted to the needs of your application.

answered by 16.09.2018 / 05:07