Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Currency creation based on a locale

To prevent the problems with your client you could simply set the wished locale manually.

= new Zend_Currency('en_US');

// You can also use the 'locale' option
// $currency = new Zend_Currency(array('locale' => 'en_US'));

// See the actual settings which are fixed to 'en_US'
// var_dump($currency);

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.

// in your bootstrap file
$locale = new Zend_Locale('de_AT');

// somewhere in your application
$currency = new Zend_Currency();

Zend Framework