| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect1 id="zend.measure.output">
- <title>Outputting measurements</title>
- <para>
- Measurements can be output in a number of different ways.
- </para>
- <para>
- <link linkend="zend.measure.output.auto">Automatic output</link>
- </para>
- <para>
- <link linkend="zend.measure.output.value">Outputting values</link>
- </para>
- <para>
- <link linkend="zend.measure.output.unit">Output with unit of measurement</link>
- </para>
- <para>
- <link linkend="zend.measure.output.unit">Output as localized string</link>
- </para>
- <sect2 id="zend.measure.output.auto">
- <title>Automatic output</title>
- <para>
- <classname>Zend_Measure</classname> supports outputting of strings automatically.
- <example id="zend.measure.output.auto.example-1">
- <title>Automatic output</title>
- <programlisting language="php"><![CDATA[
- $locale = new Zend_Locale('de');
- $mystring = "1.234.567,89";
- $unit = new Zend_Measure_Length($mystring,
- Zend_Measure_Length::STANDARD,
- $locale);
- echo $unit;
- ]]></programlisting>
- </example>
- </para>
- <note>
- <title>Measurement output</title>
- <para>
- Output can be achieved simply by using
- <ulink url="http://php.net/echo">echo</ulink> or
- <ulink url="http://php.net/print">print</ulink>.
- </para>
- </note>
- </sect2>
- <sect2 id="zend.measure.output.value">
- <title>Outputting values</title>
- <para>
- The value of a measurement can be output using <methodname>getValue()</methodname>.
- <example id="zend.measure.output.value.example-1">
- <title>Output a value</title>
- <programlisting language="php"><![CDATA[
- $locale = new Zend_Locale('de');
- $mystring = "1.234.567,89";
- $unit = new Zend_Measure_Length($mystring,
- Zend_Measure_Length::STANDARD,
- $locale);
- echo $unit->getValue();
- ]]></programlisting>
- </example>
- </para>
- <para>
- The <methodname>getValue()</methodname> method accepts an optional parameter
- <property>round</property> which allows to define a precision for the generated
- output. The standard precision is '2'.
- </para>
- </sect2>
- <sect2 id="zend.measure.output.unit">
- <title>Output with unit of measurement</title>
- <para>
- The function <methodname>getType()</methodname> returns the current unit of measurement.
- <example id="zend.measure.output.unit.example-1">
- <title>Outputting units</title>
- <programlisting language="php"><![CDATA[
- $locale = new Zend_Locale('de');
- $mystring = "1.234.567,89";
- $unit = new Zend_Measure_Weight($mystring,
- Zend_Measure_Weight::POUND,
- $locale);
- echo $unit->getType();
- ]]></programlisting>
- </example>
- </para>
- </sect2>
- <sect2 id="zend.measure.output.localized">
- <title>Output as localized string</title>
- <para>
- Outputting a string in a format common in the users' country is usually desirable. For
- example, the measurement "1234567.8" would become "1.234.567,8" for Germany. This
- functionality will be supported in a future release.
- </para>
- </sect2>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|