PhpRiot
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 informations

Sometimes it is necessary to get informations which are related to a currency. Zend_Currency provides you with several methods to get this informations. Available methods include the following:

  • getCurrencyList(): Returns a list of all currencies which are used in the given region as array. Defaults to the objects locale when no region has been given.

  • getLocale(): Returns the set locale for the actual currency.

  • getName(): Returns the full name for the actual currency. When there is no full name available for the actual currency, it will return the abbreviation for it.

  • getRegionList(): Returns a list of all regions where this currency is used as array. Defaults to the objects currency when no currency has been given.

  • getService(): Returns the set exchange service object for the actual currency.

  • getShortName(): Returns the abbreviation for the actual currency.

  • getSymbol(): Returns the currency sign for the currency. When the currency has no symbol, then it will return the abbreviation for it.

  • getValue(): Returns the set value for the actual currency.

Let's see some code snippets as example:

<?php
$currency 
= new Zend_Currency();

var_dump($currency->getValue());
// returns 0

var_dump($currency->getRegionList());
// could return an array with all regions where USD is used

var_dump($currency->getRegionList('EUR'));
// returns an array with all regions where EUR is used

var_dump($currency->getName());
// could return 'US Dollar'

var_dump($currency->getName('EUR'));
// returns 'Euro'

As you can see, several methods allow to use additional parameters to override the actual object to get informations for other currencies. Omitting this parameters will return informations from the actual set currency.

Zend Framework