September 19, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Create a Unit Conversion Application with the Zend_Measure Component

  • February 11, 2010
  • 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


Tags: open source, PHP, framework, Zend, conversion




Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel