Programmer's Reference Guide
| 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:
| 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" |
例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:
By giving the proper option you can define what information which has to be rendered.
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.
注意: 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.
例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:
You could also set a sign or an abbreviations yourself.
注意: 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 |
Select a Version
Languages Available
Components
Search the Manual
Navigation
- プログラマ向けリファレンスガイド
- プログラマ向けリファレンスガイド
- Zend Framework リファレンス
- Zend_Currency
- Zend_Currency について
- Using Zend_Currency
- Options for currencies
- What makes a currency?
- Where is the currency?
- How does the currency look like?
- How much is my currency?
- Calculating with currencies
- Exchanging currencies
- Additional informations on Zend_Currency
