Options for currencies

What makes a currency?

The currency consists of several informations. A name, a abbreviation and a sign. Each of these could be relevant to be displayed, but only one at the same time. It would not be a good practice to display something like "USD 1.000 $".

Therefor Zend_Currency supports the definition of the currency information which has to be rendered. The following constants can be used:

Rendered informations for a currency
Constant Description
NO_SYMBOL No currency representation will be rendered at all
USE_SYMBOL The currency symbol will be rendered. For US Dollar this would be '$'
USE_SHORTNAME The abbreviation for this currency will be rendered. For US Dollar this would be 'USD'. Most abbreviations consist of 3 characters
USE_NAME The full name for this currency will be rendered. For US Dollar the full name would be "US Dollar"

Example #1 Selecting the currency description

Let's assume that your client has again set "en_US" as locale. Using no option the returned value could look like this:

  1. span style="color: #ff0000;">'value'// Could return '$ 100'

By giving the proper option you can define what information which has to be rendered.

  1. span style="color: #ff0000;">'value'   => 100,
  2.         'display'// Could return 'USD 100'

Without providing the display the currency sign will be used when rendering the object. When the currency has no sign, the abbreviation will be used as replacement.

Note: Not all currencies have signs
You should note that not all currencies have default currency signs. This means, that when there is no default sign, and you set the sign to be rendered, you will not have a rendered currency at all because the sign is an empty string.

Sometimes it is necessary to change the default informations. You can set each of the three currency informations independently by giving the proper option. See the following example.

Example #2 Changing the currency description

Let's assume that your client has again set "en_US" as locale. But now we don't want to use the default settings but set our own description. This can simply be done providing the proper option:

  1. span style="color: #ff0000;">'value' => 100,
  2.         'name'  => 'Dollar'// Could return 'Dollar 100'

You could also set a sign or an abbreviations yourself.

  1. span style="color: #ff0000;">'value'    => 100,
  2.         'symbol' => '$$$'// Could return '$$$ 100'

Note: Automatic display settings
When you set a name, abbreviation or sign yourself, than this new information will automatically be set to be rendered. This simplification prevents you from setting the proper display option when you set a information.
So using the sign option you can omit display and don't neet to setting it to 'USE_SYMBOL'.


Options for currencies