[GENERIC] Zend_Translate:
[zend.git] / documentation / manual / en / module_specs / Zend_Measure-Output.xml
blob8a9ed4208bd07c4bc25a578f61e01f8a1331ee69
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- Reviewed: no -->
3 <sect1 id="zend.measure.output">
5     <title>Outputting measurements</title>
7     <para>
8         Measurements can be output in a number of different ways.
9     </para>
11     <para>
12         <link linkend="zend.measure.output.auto"><code>Automatic output</code></link>
13     </para>
15     <para>
16         <link linkend="zend.measure.output.value"><code>Outputting values</code></link>
17     </para>
19     <para>
20         <link linkend="zend.measure.output.unit"><code>Output with unit of measurement</code></link>
21     </para>
23     <para>
24         <link linkend="zend.measure.output.unit"><code>Output as localized string</code></link>
25     </para>
27     <sect2 id="zend.measure.output.auto">
28         <title>Automatic output</title>
30         <para>
31             <classname>Zend_Measure</classname> supports outputting of strings automatically.
33             <example id="zend.measure.output.auto.example-1">
34                 <title>Automatic output</title>
36                 <programlisting language="php"><![CDATA[
37 $locale = new Zend_Locale('de');
38 $mystring = "1.234.567,89";
39 $unit = new Zend_Measure_Length($mystring,
40                                 Zend_Measure_Length::STANDARD,
41                                 $locale);
43 echo $unit;
44 ]]></programlisting>
45             </example>
46         </para>
48         <note>
49             <title>Measurement output</title>
51             <para>
52                 Output can be achieved simply by using
53                 <ulink url="http://php.net/echo"><code>echo</code></ulink> or
54                 <ulink url="http://php.net/print"><code>print</code></ulink>.
55             </para>
56         </note>
57     </sect2>
59     <sect2 id="zend.measure.output.value">
60         <title>Outputting values</title>
62         <para>
63             The value of a measurement can be output using <methodname>getValue()</methodname>.
65             <example id="zend.measure.output.value.example-1">
66                 <title>Output a value</title>
68                 <programlisting language="php"><![CDATA[
69 $locale = new Zend_Locale('de');
70 $mystring = "1.234.567,89";
71 $unit = new Zend_Measure_Length($mystring,
72                                 Zend_Measure_Length::STANDARD,
73                                 $locale);
75 echo $unit->getValue();
76 ]]></programlisting>
77             </example>
78         </para>
80         <para>
81             The <methodname>getValue()</methodname> method accepts an optional parameter
82             '<code>round</code>' which allows to define a precision for the generated output. The
83             standard precision is '<code>2</code>'.
84         </para>
85     </sect2>
87     <sect2 id="zend.measure.output.unit">
88         <title>Output with unit of measurement</title>
90         <para>
91             The function <methodname>getType()</methodname> returns the current unit of measurement.
93             <example id="zend.measure.output.unit.example-1">
94                 <title>Outputting units</title>
96                 <programlisting language="php"><![CDATA[
97 $locale = new Zend_Locale('de');
98 $mystring = "1.234.567,89";
99 $unit = new Zend_Measure_Weight($mystring,
100                                 Zend_Measure_Weight::POUND,
101                                 $locale);
103 echo $unit->getType();
104 ]]></programlisting>
105             </example>
106         </para>
107     </sect2>
109     <sect2 id="zend.measure.output.localized">
110         <title>Output as localized string</title>
112         <para>
113             Outputting a string in a format common in the users' country is usually desirable. For
114             example, the measurement "1234567.8" would become "1.234.567,8" for Germany. This
115             functionality will be supported in a future release.
116         </para>
117     </sect2>
118 </sect1>
119 <!--
120 vim:se ts=4 sw=4 et: