Introducción a Zend Framework

 Aprendiendo Zend Framework


 Referencia de Zend Framework

  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Traducción al 26.9% - Actualizado el 2011-11-16 - Revisión 24249 - Versión ZF 1.11.x

    25.4. 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:

    Tabla 25.1. Rendered informations for a currency

    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"

    Ejemplo 25.2. 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:

    $currency = new Zend_Currency(
    'value' => 100,

    $currency// Could return '$ 100'

    By giving the proper option you can define what information which has to be rendered.

    $currency = new Zend_Currency(
    'value'   => 100,
    'display' => Zend_Currency::USE_SHORTNAME,

    $currency// Could return 'USD 100'

    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.

    [Nota] 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.

    Ejemplo 25.3. 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:

    $currency = new Zend_Currency(
    'value' => 100,
    'name'  => 'Dollar',

    $currency// Could return 'Dollar 100'

    You could also set a sign or an abbreviations yourself.

    $currency = new Zend_Currency(
    'value'    => 100,
    'symbol' => '$$$',

    $currency// Could return '$$$ 100'

    [Nota] 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'.

    digg delicious meneame google twitter technorati facebook