1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.measure.output">
5 <title>Outputting measurements</title>
8 Measurements can be output in a number of different ways.
12 <link linkend="zend.measure.output.auto"><code>Automatic output</code></link>
16 <link linkend="zend.measure.output.value"><code>Outputting values</code></link>
20 <link linkend="zend.measure.output.unit"><code>Output with unit of measurement</code></link>
24 <link linkend="zend.measure.output.unit"><code>Output as localized string</code></link>
27 <sect2 id="zend.measure.output.auto">
28 <title>Automatic output</title>
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,
49 <title>Measurement output</title>
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>.
59 <sect2 id="zend.measure.output.value">
60 <title>Outputting values</title>
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,
75 echo $unit->getValue();
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>'.
87 <sect2 id="zend.measure.output.unit">
88 <title>Output with unit of measurement</title>
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,
103 echo $unit->getType();
109 <sect2 id="zend.measure.output.localized">
110 <title>Output as localized string</title>
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.