<?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:
-->
