2 votes

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 () someone can help me

0 votes

Where do you get this function from or where is it declared?

2voto

A. Cedano Points 48884

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

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

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

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

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

With these two starting points, you can tackle the problem with your own function, tailored to the needs of your application.

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X