bobo
bobo

Reputation: 8727

Required conversion character in money_format ( string $format , float $number ) function

From http://us.php.net/manual/en/function.money-format.php,

It says the $format should consists of the following sequence:

  1. a % character
  2. optional flags
  3. optional field width
  4. optional left precision
  5. optional right precision
  6. a required conversion character

For the number 6 which is the conversion character part, it says we can have three choices:

i - The number is formatted according to the locale's international currency format (e.g. for the USA locale: USD 1,234.56).

n - The number is formatted according to the locale's national currency format (e.g. for the de_DE locale: EU1.234,56).

% - Returns the % character.

I understand i and n, but I don't really understand the use of %.

For example, this works,

http://ideone.com/xxg55

If I use % instead of i in the conversion character part, it produces an error:

http://ideone.com/XmLjY

Upvotes: 0

Views: 372

Answers (1)

Jon
Jon

Reputation: 437376

It's just so that you can write %% if you want a literal % to appear in your output.

Upvotes: 2

Related Questions