2
0

Zend_Currency-Description.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.currency.description">
  4. <title>What makes a currency?</title>
  5. <para>
  6. The currency consists of several informations. A name, a abbreviation and a sign. Each
  7. of these could be relevant to be displayed, but only one at the same time. It would not
  8. be a good practice to display something like "USD 1.000 $".
  9. </para>
  10. <para>
  11. Therefor <classname>Zend_Currency</classname> supports the definition of the currency
  12. information which has to be rendered. The following constants can be used:
  13. </para>
  14. <table id="zend.currency.description.table-1">
  15. <title>Rendered informations for a currency</title>
  16. <tgroup cols="2" align="left">
  17. <thead>
  18. <row>
  19. <entry>Constant</entry>
  20. <entry>Description</entry>
  21. </row>
  22. </thead>
  23. <tbody>
  24. <row>
  25. <entry><constant>NO_SYMBOL</constant></entry>
  26. <entry>No currency representation will be rendered at all</entry>
  27. </row>
  28. <row>
  29. <entry><constant>USE_SYMBOL</constant></entry>
  30. <entry>
  31. The currency symbol will be rendered. For US Dollar this would be '$'
  32. </entry>
  33. </row>
  34. <row>
  35. <entry><constant>USE_SHORTNAME</constant></entry>
  36. <entry>
  37. The abbreviation for this currency will be rendered. For US Dollar this
  38. would be 'USD'. Most abbreviations consist of 3 characters
  39. </entry>
  40. </row>
  41. <row>
  42. <entry><constant>USE_NAME</constant></entry>
  43. <entry>
  44. The full name for this currency will be rendered. For US Dollar the full
  45. name would be "US Dollar"
  46. </entry>
  47. </row>
  48. </tbody>
  49. </tgroup>
  50. </table>
  51. <example id="zend.currency.description.example-1">
  52. <title>Selecting the currency description</title>
  53. <para>
  54. Let's assume that your client has again set "en_US" as locale. Using no option the
  55. returned value could look like this:
  56. </para>
  57. <programlisting language="php"><![CDATA[
  58. $currency = new Zend_Currency(
  59. array(
  60. 'value' => 100,
  61. )
  62. );
  63. print $currency; // Could return '$ 100'
  64. ]]></programlisting>
  65. <para>
  66. By giving the proper option you can define what information which has to be
  67. rendered.
  68. </para>
  69. <programlisting language="php"><![CDATA[
  70. $currency = new Zend_Currency(
  71. array(
  72. 'value' => 100,
  73. 'display' => Zend_Currency::USE_SHORTNAME,
  74. )
  75. );
  76. print $currency; // Could return 'USD 100'
  77. ]]></programlisting>
  78. <para>
  79. Without providing the <property>display</property> the currency sign will be used
  80. when rendering the object. When the currency has no sign, the abbreviation will be
  81. used as replacement.
  82. </para>
  83. </example>
  84. <note>
  85. <title>Not all currencies have signs</title>
  86. <para>
  87. You should note that not all currencies have default currency signs. This means,
  88. that when there is no default sign, and you set the sign to be rendered, you will
  89. not have a rendered currency at all because the sign is an empty string.
  90. </para>
  91. </note>
  92. <para>
  93. Sometimes it is necessary to change the default informations. You can set each of the
  94. three currency informations independently by giving the proper option. See the following
  95. example.
  96. </para>
  97. <example id="zend.currency.description.example-2">
  98. <title>Changing the currency description</title>
  99. <para>
  100. Let's assume that your client has again set "en_US" as locale. But now we don't want
  101. to use the default settings but set our own description. This can simply be done
  102. providing the proper option:
  103. </para>
  104. <programlisting language="php"><![CDATA[
  105. $currency = new Zend_Currency(
  106. array(
  107. 'value' => 100,
  108. 'name' => 'Dollar',
  109. )
  110. );
  111. print $currency; // Could return 'Dollar 100'
  112. ]]></programlisting>
  113. <para>
  114. You could also set a sign or an abbreviations yourself.
  115. </para>
  116. <programlisting language="php"><![CDATA[
  117. $currency = new Zend_Currency(
  118. array(
  119. 'value' => 100,
  120. 'symbol' => '$$$',
  121. )
  122. );
  123. print $currency; // Could return '$$$ 100'
  124. ]]></programlisting>
  125. </example>
  126. <note>
  127. <title>Automatic display settings</title>
  128. <para>
  129. When you set a name, abbreviation or sign yourself, than this new information will
  130. automatically be set to be rendered. This simplification prevents you from setting
  131. the proper <property>display</property> option when you set a information.
  132. </para>
  133. <para>
  134. So using the <property>sign</property> option you can omit
  135. <property>display</property> and don't neet to setting it to
  136. '<constant>USE_SYMBOL</constant>'.
  137. </para>
  138. </note>
  139. </sect1>