Using Zend_Currency | Zend_Currency Programmer's Reference Guide | What makes a currency?

# Options for currencies

Depending on your needs, several options can be specified at instantiation. All of this options have default values. But sometimes it is necessary to define how your currencies will be rendered. This includes for example:

- Currency symbol, shortname or name:

  Zend_Currency knows all currency names, abbreviations and signs. But sometimes you could be in need to define the string which has to be displayed as replacement for a currency.

- Currency position:

  The position of the currency symbol is automatically defined. But sometimes you could be in need to define it manually.

- Script:

  You could define the script which shall be used to display digits. Detailed information about scripts and their usage can be found in Zend_Locale's chapter Numeral System Conversion.

- Number formatting:

  The amount of currency (generally known as money value) is formatted by using the formatting rules defined by the locale. For example is the ',' sign in English used as separator for thousands, but in German as precision sign.

The following list mentions all options which could be set. They can either be set at initiation or by using the setFormat() method. In any case you have to give this options as array.

- currency: Defines the abbreviation which can be displayed.

- display: Defines which part of the currency should be used for displaying the currency representation. There are 4 representations which can be used and which are all described in this table.

- format: Defines the format which should be used for displaying numbers. This number-format includes for example the thousand separator. You can either use a default format by giving a locale identifier, or define the number-format manually. If no format is set the locale from the Zend_Currency object will be used. See the chapter about number formatting for details.

- locale: Defines a locale for this currency. It will be used for detecting the default values when other settings are omitted. Note that when you don't set a locale yourself, it will be detected automatically which could lead to problems.

- name: Defines the full currency name which can be displayed.

- position: Defines the position at which the currency description should be displayed. The supported positions are described this section.

- precision: Defines the precision which should be used for the currency representation. The default value depends on the locale and is for most locales 2.

- script: Defined which script should be used for displaying digits. The default script for most locales is 'Latn', which includes the digits 0 to 9. Other scripts such as 'Arab' (Arabian) are using other digits. See the chapter about numbering systems for details and available options.

- service: Defines the exchange service which has to be used when calculating with different currencies.

- symbol: Defines the currency symbol which can be displayed.

- value: Defines the currency amount (money value). Using this option you should also set the service option.

As you can see there is much which could be changed. Still as already mentioned the default values for this settings conform the official standard for currency representation in every country.

Using Zend_Currency | Zend_Currency Programmer's Reference Guide | What makes a currency?