18.6. Types of measurements
السابق | فصل 18. Zend_Measure | التالي

## 18.6. Types of measurements

### 18.6.1. Zend_Measure_Acceleration

`Zend_Measure_Acceleration` covers the physical factor of acceleration.

| Standard unit
The standard measurement unit is meter per square second (`m/s²`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Acceleration');

    // define standard measurement unit
    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::ACCELERATION, $locale);

    // convert to km/s²
    echo $unit->convertTo(Zend_Measure_Acceleration::KILOMETER_PER_SQUARE_SECOND);
    ?>

### 18.6.2. Zend_Measure_Angle

`Zend_Measure_Angle` covers angular dimensions.

| Standard unit
The standard measurement unit is radiant (`rad`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Angle');

    $locale = new Zend_Locale('en');
    $angle = new Zend_Measure(100,Zend_Measure::ANGLE, $locale);

    // add a second angle
    $second = new Zend_Measure(30,Zend_Measure::ANGLE, $locale);
    $sum = $angle->add($second);

    echo $sum->convertTo(Zend_Measure_Angle::DEGREE);
    ?>

### 18.6.3. Zend_Measure_Area

`Zend_Measure_Area` covers square measures.

| Standard unit
The standard measurement unit is square meter (`m²`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Area');

    // define another measurement... here hectare
    $locale = new Zend_Locale('en');
    $area = new Zend_Measure(100,Zend_Measure_Area::HECTARE, $locale);

    // convert to the standard measurement unit Zend_Measure_Area::SQUARE_METER
    echo $area->convertTo(Zend_Measure_Area::STANDARD);
    ?>

### 18.6.4. Zend_Measure_Binary

`Zend_Measure_Binary` covers binary convertions.

| Standard unit
The standard measurement unit is byte (`b`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Binary');

    $locale = new Zend_Locale('en');
    $binary = new Zend_Measure(100,Zend_Measure_Binary::MEGABYTE, $locale);

    // convert to the measurement unit megabyte as defined by SI
    echo $binary->convertTo(Zend_Measure_Binary::MEGABYTE_SI);
    ?>

| Binary conventions
The terms kilo-, mega-, giga and so on... have to be seen, in the normal language use, for 1000 or 10³. In the binary format for computers the terms kilo-, mega-, giga- and so on have to be seen for a convertion factor of 1024 instead of 1000. To preclude confusions a few years ago the notation BI was introduced. Instead of kilobyte, kibibyte for kilo-binary-byte should be used. In the class BINARY both notations can be found. KILOBYTE = 1024 - binary conputer conversion KIBIBYTE = 1024 - new notation KILO_BINARY_BYTE = 1024 - new notation, long format KILOBYTE_SI = 1000 - SI notation for kilo (1000) DVDs for example are marked with the SI-notation, but almost all harddisks are marked in computer binary notation.

### 18.6.5. Zend_Measure_Capacitance

`Zend_Measure_Capacitance` covers the physical factor of capacitance.

| Standard unit
The standard measurement unit is farad (`F`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Capacitance.');

    // definition of the measurement as string
    $locale = new Zend_Locale('en');
    $capacity = new Zend_Measure('100 Farad',Zend_Measure::CAPACITANCE, $locale);

    // output value
    echo $capacity;
    ?>

### 18.6.6. Zend_Measure_Cooking_Volume

`Zend_Measure_Cooking_Volume` covers volumes which are used for cooking or written in cookbooks.

This class is a reduced version of the class `Zend_Measure_Volume`, but it covers only the measurement units which are needed for cooking.

| Standard unit
The standard measurement unit is cubic meter (`m³`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Cooking_Volume');

    // define the measurement unit as extended string
    $locale = new Zend_Locale('de');
    $rum = new Zend_Measure('You will need 10cl rum',Zend_Measure_Cooking_Volume::CENTILITER, $locale);

    // output value
    echo $rum;
    ?>

### 18.6.7. Zend_Measure_Cooking_Weight

`Zend_Measure_Cooking_Weight` covers the weights which are used for cooking or written in cookbooks.

This class is a reduced version of the class `Zend_Measure_Weight`, but it covers only the measurement units which are neededfor cooking.

| Standard unit
The standard measurement unit is gram (`g`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Cooking_Weight');

    // extract the measurement unit from an localized string
    $locale = new Zend_Locale('de');
    $rum = new Zend_Measure('The cake needs 2,5g oil',Zend_Measure_Cooking_Weight::GRAM, $locale);

    // output value
    echo $rum;
    ?>

### 18.6.8. Zend_Measure_Current

`Zend_Measure_Current` covers the physical factor of current.

| Standard unit
The standard measurement unit is ampere (`A`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Current');

    // extract the measurement unit from an localized string with number grouping
    $locale = new Zend_Locale('de');
    $unit = new Zend_Measure('1.200,50Ampere',Zend_Measure::CURRENT, $locale);

    echo $unit->convertTo(Zend_Measure_Current::KILOAMPERE);
    ?>

### 18.6.9. Zend_Measure_Density

`Zend_Measure_Density` covers the physical factor of density.

| Standard unit
The standard measurement unit is kilogram per cubic meter (`kg/m³`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Density');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::DENSITY, $locale);

    echo $unit;
    ?>

### 18.6.10. Zend_Measure_Energy

`Zend_Measure_Energy` covers the physical factor of energy.

| Standard unit
The standard measurement unit is joule (`J`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Energy');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::ENERGY, $locale);

    echo $unit;
    ?>

### 18.6.11. Zend_Measure_Force

`Zend_Measure_Force` covers the physical factor of force.

| Standard unit
The standard measurement unit is newton (`N`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Energy');

    $locale = new Zend_Locale('de');
    $unit = new Zend_Measure(100,Zend_Measure::ENERGY, $locale);

    echo $unit;
    ?>

### 18.6.12. Zend_Measure_Flow_Mass

`Zend_Measure_Flow_Mass` covers the physical factor of flow rate. The weight of the flowing mass is used as reference point within this class.

| Standard unit
The standard measurement unit is kilogram per second (`kg/s`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Flow_Mass');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::FLOW_MASS, $locale);

    echo $unit;
    ?>

### 18.6.13. Zend_Measure_Flow_Mole

`Zend_Measure_Flow_Mole` covers the physical factor of flow rate. The density of the flowing mass is used as reference point within this class.

| Standard unit
The standard measurement unit is mole per second (`mol/s`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Flow_Mole');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::FLOW_MOLE, $locale);

    echo $unit;
    ?>

### 18.6.14. Zend_Measure_Flow_Volume

`Zend_Measure_Flow_Volume` covers the physical factor of flow rate. The volume of the flowing mass is used as reference point within this class.

| Standard unit
The standard measurement unit is cubic meter per second (`m³/s`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Flow_Volume');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::FLOW_VOLUME, $locale);

    echo $unit;
    ?>

### 18.6.15. Zend_Measure_Frequency

`Zend_Measure_Frequency` covers the physical factor of frequency.

| Standard unit
The standard measurement unit is hertz (`Hz`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Frequency');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::FREQUENCY, $locale);

    echo $unit;
    ?>

### 18.6.16. Zend_Measure_Illumination

`Zend_Measure_Illumination` covers the physical factor of light density.

| Standard unit
The standard measurement unit is lux (`lx`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Illumination');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::ILLUMINATION, $locale);

    echo $unit;
    ?>

### 18.6.17. Zend_Measure_Length

`Zend_Measure_Length` covers the physical factor of length.

| Standard unit
The standard measurement unit is meter (`m`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Length');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::LENGTH, $locale);

    echo $unit;
    ?>

### 18.6.18. Zend_Measure_Lightness

`Zend_Measure_Lightness` covers the physical factor of light energy.

| Standard unit
The standard measurement unit is candela per square meter (`cd/m²`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Lightness');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::LIGHTNESS, $locale);

    echo $unit;
    ?>

### 18.6.19. Zend_Measure_Number

`Zend_Measure_Number` can convert between number formats.

| Standard unit
The standard unit is decimal.

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Number');

    $locale = new Zend_Locale('en');
    $binary = new Zend_Measure('10010110',Zend_Measure_Number::BINARY, $locale);

    // convert to roman number format
    echo $binary->convertTo(Zend_Measure_Number::ROMAN);
    ?>

The best known number format is the decimal system.

Additionaly this class covers the octal system, the hexadecimal system, the binary system, the roman number format and a few not so familiar systems.

| Be aware
Be aware that only the decimal part of numbers is handled. The fractional part will be stripped.

| Roman numbers
For the roman numbersystem digits greater 4000 are supported. In reality these digits are shown with a crossbeam on top of the digit. As the crossbeam can not be shown within the computer, an underline has to be used instead of it.
    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Number');

    $great = '_X';
    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure($great,Zend_Measure_Number::ROMAN, $locale);

    // convert to the decimal system
    echo $unit->convertTo(Zend_Measure_Number::DECIMAL);
    ?>

### 18.6.20. Zend_Measure_Power

`Zend_Measure_Power` covers the physical factor of power.

| Standard unit
The standard measurement unit is watt (`W`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Power');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::POWER, $locale);

    echo $unit;
    ?>

### 18.6.21. Zend_Measure_Pressure

`Zend_Measure_Pressure` covers the physical factor of pressure.

| Standard unit
The standard measurement unit is newton per square meter (`N/m²`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Pressure');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::PRESSURE, $locale);

    echo $unit;
    ?>

### 18.6.22. Zend_Measure_Speed

`Zend_Measure_Speed` covers the physical factor of speed.

| Standard unit
The standard measurement unit is meter per second (`m/s`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Speed');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::SPEED, $locale);

    echo $unit;
    ?>

### 18.6.23. Zend_Measure_Temperature

`Zend_Measure_Temperature` covers the physical factor of temperature.

| Standard unit
The standard measurement unit is kelvin (`K`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Temperature');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::TEMPERATURE, $locale);

    echo $unit;
    ?>

### 18.6.24. Zend_Measure_Torque

`Zend_Measure_Torque` covers the physical factor of torque.

| Standard unit
The standard measurement unit is newton meter (`Nm`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Torque');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::TORQUE, $locale);

    echo $unit;
    ?>

### 18.6.25. Zend_Measure_Viscosity_Dynamic

`Zend_Measure_Viscosity_Dynamic` covers the physical factor of viscosity. The weight of the fluid is used as reference point within this class.

| Standard unit
The standard measurement unit is kilogram per meter second (`kg/ms`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Viscosity_Dynamic');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::VISCOSITY_DYNAMIC, $locale);

    echo $unit;
    ?>

### 18.6.26. Zend_Measure_Viscosity_Kinematic

`Zend_Measure_Viscosity_Kinematic` covers the physical factor of viscosity. The distance of the flown fluid is used as reference point within this class.

| Standard unit
The standard measurement unit is square meter per second (`m²/s`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Viscosity_Kinematic');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::VISCOSITY_KINEMATIC, $locale);

    echo $unit;
    ?>

### 18.6.27. Zend_Measure_Volume

`Zend_Measure_Volume` covers the physical factor of volume (content).

| Standard unit
The standard measurement unit is cubic meter (`m³`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Volume');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::VOLUME, $locale);

    echo $unit;
    ?>

### 18.6.28. Zend_Measure_Weight

`Zend_Measure_Weight` covers the physical factor of weight.

| Standard unit
The standard measurement unit is kilogram (`kg`).

    <?php
    require_once 'Zend.php';
    Zend::loadClass('Zend_Measure');
    Zend::loadClass('Zend_Measure_Weight');

    $locale = new Zend_Locale('en');
    $unit = new Zend_Measure(100,Zend_Measure::WEIGHT, $locale);

    echo $unit;
    ?>

السابق | أعلى | التالي
18.5. Special functions | البداية | فصل 19. Zend_Mime