Zend_Currency-Position.xml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.currency.position">
  4. <title>Where is the currency?</title>
  5. <para>
  6. The position where the currency sign or name will be displayed depends on the locale.
  7. Still, when you want to define this setting yourself you have to use the
  8. <property>display</property> option and provide one of the following constants:
  9. </para>
  10. <table id="zend.currency.position.table-1">
  11. <title>Available positions for the currency</title>
  12. <tgroup cols="2" align="left">
  13. <thead>
  14. <row>
  15. <entry>Constant</entry>
  16. <entry>Description</entry>
  17. </row>
  18. </thead>
  19. <tbody>
  20. <row>
  21. <entry><constant>STANDARD</constant></entry>
  22. <entry>Sets the standard position as defined within the locale</entry>
  23. </row>
  24. <row>
  25. <entry><constant>RIGHT</constant></entry>
  26. <entry>
  27. Displays the currency representation at the right side of the value
  28. </entry>
  29. </row>
  30. <row>
  31. <entry><constant>LEFT</constant></entry>
  32. <entry>
  33. Displays the currency representation at the left side of the value
  34. </entry>
  35. </row>
  36. </tbody>
  37. </tgroup>
  38. </table>
  39. <example id="zend.currency.position.example-1">
  40. <title>Setting the currency position</title>
  41. <para>
  42. Let's assume that your client has again set "en_US" as locale. Using no option the
  43. returned value could look like this:
  44. </para>
  45. <programlisting language="php"><![CDATA[
  46. $currency = new Zend_Currency(
  47. array(
  48. 'value' => 100,
  49. )
  50. );
  51. print $currency; // Could return '$ 100'
  52. ]]></programlisting>
  53. <para>
  54. So by using the default setting the currency (in our case $) could either be
  55. rendered left or right from the value. Now let's define a fixed position:
  56. </para>
  57. <programlisting language="php"><![CDATA[
  58. $currency = new Zend_Currency(
  59. array(
  60. 'value' => 100,
  61. 'position' => Zend_Currency::RIGHT,
  62. )
  63. );
  64. print $currency; // Could return '100 $';
  65. ]]></programlisting>
  66. <para>
  67. Note that in the second snippet the position of <acronym>USD</acronym> is fixed
  68. regardless of the used locale or currency.
  69. </para>
  70. </example>
  71. </sect1>