Why have you got the Fatal Error: Call to undefined function money_format()?

Whenever you run the code related to currency, have you ever seen the Fatal Error: Call to undefined function money_format()? If this error appears, that means you use the function money_format() in the system that doesn’t have strfmon capabilities. For instance, if you are utilizing Windows as a based system, the function money_format() is undefined since Windows doesn’t have strfmon capabilities. You can read more information here.

So, if you are looking for a helpful solution to deal with this issue quickly, don’t hesitate to continue reading the blog today. Let’s move on to the fixing method now!

How to fix Fatal Error: Call to undefined function money_format()?

Because the function money_format() doesn’t appear on your system, you should write your own function based on the number_format function.

If you want to format the number as US dollars, it’s a great suggestion for you to use:

  • Decimal =.
  • Thousands =,

function asDollars($value) {
if ($value<0) return "-".asDollars(-$value);
return '$' . number_format($value, 2);
}

For example, the code line containing the error is:

$pricetotal = money_format("%10.2n", $pricetotal);

We will change it into:

$pricetotal = asDollars($pricetotal);

Wind-up

In conclusion, we hope that the recommended method above can help you address the trouble. If you have other ideas to remove the error, don’t hesitate to share them with us and other users by leaving your comment below.

Last but not least, we are offering a lot of mobile-friendly and eye-catching Joomla 4 Templates and free WordPress Themes. So, don’t forget to have a look at them and get the best one for your site. Hope you enjoy it and have a wonderful day.

5/5 - (1 vote)
Lt Digital Team (Content &Amp; Marketing)

Summer Sale Grab 50% Off for everything on today, don't miss it. Coupon code: SUMMER2024 Redeem Now
Summer Sale Grab 50% Off for everything on today, don't miss it. Coupon code: SUMMER2024 Redeem Now