Caution: The documentation you are viewing is
for an older version of Zend Framework.
You can find the documentation of the current version at docs.zendframework.com
Introduction - Zend_Measure
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.
Example #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.
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
Types of measurements.
Example #2 The meter measurement
meter is used for measuring lengths, so its type constant can be found
Length class. To refer to this unit of measurement, the notation
Length::METER must be used. The display unit is