Zend_Measure-Output.xml 3.8 KB

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