Introduction to Zend Framework

 Learning Zend Framework

appendix

 Zend Framework Reference


  •  Zend_Gdata
  •  Zend_Http
  •  Zend_InfoCard
  •  Zend_Json
  •  Zend_Layout
  •  Zend_Ldap
  •  Zend_Loader
  •  Zend_Locale
  •  Zend_Log
  •  Zend_Mail
  •  Zend_Markup
  •  Zend_Measure
  •  Zend_Memory
  •  Zend_Mime
  •  Zend_Navigation
  •  Zend_Oauth
  •  Zend_OpenId
  •  Zend_Paginator
  •  Zend_Pdf
  •  Zend_ProgressBar
  •  Zend_Queue
  •  Zend_Reflection
  •  Zend_Registry
  •  Zend_Rest

  •  Zend_Search_Lucene
  •  Zend_Serializer
  •  Zend_Server
  •  Zend_Service
  •  Zend_Session
  •  Zend_Soap
  •  Zend_Tag
  •  Zend_Test
  •  Zend_Text
  •  Zend_TimeSync
  •  Zend_Tool
  •  Zend_Tool_Framework
  •  Zend_Tool_Project
  •  Zend_Translate
  •  Zend_Uri
  •  Zend_Validate
  •  Zend_Version
  •  Zend_View
  •  Zend_Wildfire
  •  Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Update 2011-11-16 - Revision 24438 - Version ZF 1.11.x

    47.3. Outputting measurements

    Measurements can be output in a number of different ways.

    Automatic output

    Outputting values

    Output with unit of measurement

    Output as localized string

    47.3.1. Automatic output

    Zend_Measure supports outputting of strings automatically.

    Example 47.6. Automatic output

    $locale = new Zend_Locale('de');
    $mystring "1.234.567,89";
    $unit = new Zend_Measure_Length($mystring,
                                    
    Zend_Measure_Length::STANDARD,
                                    
    $locale);

    echo 
    $unit;


    [Note] Measurement output

    Output can be achieved simply by using echo or print.

    47.3.2. Outputting values

    The value of a measurement can be output using getValue().

    Example 47.7. Output a value

    $locale = new Zend_Locale('de');
    $mystring "1.234.567,89";
    $unit = new Zend_Measure_Length($mystring,
                                    
    Zend_Measure_Length::STANDARD,
                                    
    $locale);

    echo 
    $unit->getValue();


    The getValue() method accepts an optional parameter round which allows to define a precision for the generated output. The standard precision is '2'.

    47.3.3. Output with unit of measurement

    The function getType() returns the current unit of measurement.

    Example 47.8. Outputting units

    $locale = new Zend_Locale('de');
    $mystring "1.234.567,89";
    $unit = new Zend_Measure_Weight($mystring,
                                    
    Zend_Measure_Weight::POUND,
                                    
    $locale);

    echo 
    $unit->getType();


    47.3.4. Output as localized string

    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.

    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...