Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 696 Bytes

0427.md

File metadata and controls

21 lines (17 loc) · 696 Bytes

One way to format currencies in PHP is to use the built-in money_format() function. Before using it you must set the locale for the type of currency you're trying to format. What is the output of the following PHP script? The currency name for en_US is USD and uses $ as the currency symbol. Additionally, there are 100 cents to the dollar.

setlocale(LC_MONETARY'en_US');
$amt = 100;
echo money_format('%.2n'$amt);
  • A) $100.00
  • B) USD100.0
  • C) $1.00
  • D) USD $100
Answer

Answer: A