Wprowadzenie do Zend Framework

     Nauka Zend Framework


     Przewodnik po Zend Framework

  • 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
  • Translation 21.3% Update 2011-11-16 - Revision 24356 - Version ZF 1.11.x

    Rozdział 45. Zend_Measure

    45.1. Introduction

    Zend_Measure_* classes provide a generic and easy way for working with measurements. Using Zend_Measure_* classes, you can convert measurements into different units of the same type. They can be added, subtracted and compared against each other. From a given input made in the user's native language, the unit of measurement can be automatically extracted. Numerous units of measurement are supported.

    Przykład 45.1. Converting measurements

    The following introductory example shows automatic conversion of units of measurement. To convert a measurement, its value and its type have to be known. The value can be an integer, a float, or even a string containing a number. Conversions are only possible for units of the same type (mass, area, temperature, velocity, etc.), not between types.

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure_Length(100Zend_Measure_Length::METER$locale);

    // Convert meters to yards
    echo $unit->convertTo(Zend_Measure_Length::YARD);

    Zend_Measure_* includes support for many different units of measurement. The units of measurement all have a unified notation: Zend_Measure_<TYPE>::NAME_OF_UNIT, where <TYPE> corresponds to a well-known physical or numerical property. . Every unit of measurement consists of a conversion factor and a display unit. A detailed list can be found in the chapter Types of measurements.

    Przykład 45.2. The meter measurement

    The meter is used for measuring lengths, so its type constant can be found in the Length class. To refer to this unit of measurement, the notation Length::METER must be used. The display unit is m.

    echo Zend_Measure_Length::STANDARD;  // outputs 'Length::METER'
    echo Zend_Measure_Length::KILOMETER// outputs 'Length::KILOMETER'

    $unit = new Zend_Measure_Length(100,'METER');
    // outputs '100 m'

    digg delicious meneame google twitter technorati facebook