Call to undefined function money_format

While setting up a local copy of a Magento based e-commerce site on my Windows machine, I was presented with a number of messages stating, "Fatal error: Call to undefined function money_format()." After a little research I was able to discover that this particular PHP function is not available on the Windows platform.

In order to get access to a version of the function that would be available from anywhere in the site's php code, I used the Apache auto_prepend_file directive in my php.ini file:

auto_prepend_file = "C:\path\to\money_format.php"

Then I created a money_format.php file containing a function called money_format() that wraps the PHP function number_format() (which does work on Windows) and voila, after restarting Apache, all the calls to money_format in my Magento site resolve using my custom function.

Here is the code I used for my (admittedly basic) wrapper function in case it may help anyone.

<?php
  function money_format($junk, $number) {
    return number_format($number, 2);
  }
?>

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options

CAPTCHA
This question tests whether you are a human visitor, to prevent automated spam submissions.
Question text provided by textcaptcha.com