Why does this error occurs?
code:
setlocale(LC_MONETARY, "en_US");
$pricetotal = money_format("%10.2n", $pricetotal);
Server details.
Apache Version : 2.2.21
PHP Version : 5.3.8
I'm getting the following Error
Fatal error: Call to undefined function money_format()
From the manual:
The function
money_format()
is only defined if the system hasstrfmon
capabilities. For example, Windows does not, somoney_format()
is undefined in Windows.
money_format()
is basically a wrapper around the C library function strfmon()
as the manual states.
If you check the comments, there is an implementation by Rafael M. Salvioni. Worth a try. You can check if it's already defined using function_exists().
Answers to this StackOverflow question give further (and possibly better) alternatives (thx danielson317).
For those that money_format doesn't work, you can use:
$price = number_format($price, 2); echo “$”.$price;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With