Using Zend_CurrencyGeneric usageThe simplest usecase within an application is to use the clients locale. When you create a instance of Zend_Currency without giving any options, your clients locale will be used to set the proper currency. Example #1 Creating a currency with client settings Let's assume that your client has set "en_US" as wished language within his browser. In this case Zend_Currency will automatically detect the currency which has to be used.
The created object would now contain the currency "US Dollar" as this is the actual assigned currency for US (United States). It has also other options set, like "$" for the currency sign or "USD" for the abbreviation.
Currency creation based on a localeTo prevent the problems with your client you could simply set the wished locale manually.
As within our first example the used currency will be "US Dollar". But now we are no longer dependend on the clients settings. Zend_Currency also supports the usage of an application-wide locale. You can set a Zend_Locale instance in the registry as shown below. With this notation you can avoid setting the locale manually for each instance when you want to use the same locale throughout the application.
Currency creation based on a countryZend_Currency is also able to work on a given country by using Zend_Locale internally.
|
|