January 16, 2021
Hot Topics:

Create a Unit Conversion Application with the Zend_Measure Component

  • By Jason Gilmore
  • Send Email »
  • More Articles »

The Zend Framework's Zend_Measure component can convert between an enormous number of measurement formats. This useful tool carries out not only typical unit conversions such as between miles and kilometers, but also between a wide variety of scientific formats such as torque, frequency, force, illumination, current, and density.

Of course, performing even relatively simple conversion calculations from memory can be fairly difficult, let alone calculating more esoteric conversions such as from square meters to acres. To automate this conversion process, PHP Guru Jason Gilmore used the Zend Framework and the Zend_Measure component to create a measurement-calculator capable of easily migrating data among the most commonly used formats. In his PHPBuilder tutorial, he shows you how to create your own.

To use the Zend_Measure component, you start by defining the originating unit type and value, and then calling the convertTo() method to convert the value to the desired destination unit type. Therefore, to convert a value from one standard to another, you statically call the respective class constants. Each Zend_Measure class (Zend_Measure_Length, Zend_Measure_Volume, Zend_Measure_Area, etc.) contains a well-organized list of class constants at the top of the file.

Read the full story at PHPBuilder:
Create a Unit Conversion Application with the Zend_Measure Component

This article was originally published on February 12, 2010

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date