2
0

Zend_Measure-Output.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.measure.output">
  4. <title>Outputting measurements</title>
  5. <para>
  6. Measurements can be output in a number of different ways.
  7. </para>
  8. <para>
  9. <link linkend="zend.measure.output.auto">Automatic output</link>
  10. </para>
  11. <para>
  12. <link linkend="zend.measure.output.value">Outputting values</link>
  13. </para>
  14. <para>
  15. <link linkend="zend.measure.output.unit">Output with unit of measurement</link>
  16. </para>
  17. <para>
  18. <link linkend="zend.measure.output.unit">Output as localized string</link>
  19. </para>
  20. <sect2 id="zend.measure.output.auto">
  21. <title>Automatic output</title>
  22. <para>
  23. <classname>Zend_Measure</classname> supports outputting of strings automatically.
  24. <example id="zend.measure.output.auto.example-1">
  25. <title>Automatic output</title>
  26. <programlisting language="php"><![CDATA[
  27. $locale = new Zend_Locale('de');
  28. $mystring = "1.234.567,89";
  29. $unit = new Zend_Measure_Length($mystring,
  30. Zend_Measure_Length::STANDARD,
  31. $locale);
  32. echo $unit;
  33. ]]></programlisting>
  34. </example>
  35. </para>
  36. <note>
  37. <title>Measurement output</title>
  38. <para>
  39. Output can be achieved simply by using
  40. <ulink url="http://php.net/echo">echo</ulink> or
  41. <ulink url="http://php.net/print">print</ulink>.
  42. </para>
  43. </note>
  44. </sect2>
  45. <sect2 id="zend.measure.output.value">
  46. <title>Outputting values</title>
  47. <para>
  48. The value of a measurement can be output using <methodname>getValue()</methodname>.
  49. <example id="zend.measure.output.value.example-1">
  50. <title>Output a value</title>
  51. <programlisting language="php"><![CDATA[
  52. $locale = new Zend_Locale('de');
  53. $mystring = "1.234.567,89";
  54. $unit = new Zend_Measure_Length($mystring,
  55. Zend_Measure_Length::STANDARD,
  56. $locale);
  57. echo $unit->getValue();
  58. ]]></programlisting>
  59. </example>
  60. </para>
  61. <para>
  62. The <methodname>getValue()</methodname> method accepts an optional parameter
  63. <property>round</property> which allows to define a precision for the generated
  64. output. The standard precision is '2'.
  65. </para>
  66. </sect2>
  67. <sect2 id="zend.measure.output.unit">
  68. <title>Output with unit of measurement</title>
  69. <para>
  70. The function <methodname>getType()</methodname> returns the current unit of measurement.
  71. <example id="zend.measure.output.unit.example-1">
  72. <title>Outputting units</title>
  73. <programlisting language="php"><![CDATA[
  74. $locale = new Zend_Locale('de');
  75. $mystring = "1.234.567,89";
  76. $unit = new Zend_Measure_Weight($mystring,
  77. Zend_Measure_Weight::POUND,
  78. $locale);
  79. echo $unit->getType();
  80. ]]></programlisting>
  81. </example>
  82. </para>
  83. </sect2>
  84. <sect2 id="zend.measure.output.localized">
  85. <title>Output as localized string</title>
  86. <para>
  87. Outputting a string in a format common in the users' country is usually desirable. For
  88. example, the measurement "1234567.8" would become "1.234.567,8" for Germany. This
  89. functionality will be supported in a future release.
  90. </para>
  91. </sect2>
  92. </sect1>
  93. <!--
  94. vim:se ts=4 sw=4 et:
  95. -->