Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store


Probably the most important feature is the conversion into different units of measurement. The conversion of a unit can be done any number of times using the method convertTo(). Units of measurement can only be converted to other units of the same type (class). Therefore, it is not possible to convert (e.g.) a length into a weight, which would might encourage poor programming practices and allow errors to propagate without exceptions.

The convertTo() method accepts an optional parameter. With this parameter you can define an precision for the returned output. The standard precision is '2'.

Example 614. Convert

= new Zend_Locale('de');
$mystring "1.234.567,89";
$unit = new Zend_Measure_Weight($mystring,'POND'$locale);


// constants are considered "better practice" than strings
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON);

// define a precision for the output
print "Ton:".$unit->convertTo(Zend_Measure_Weight::TON3);

Zend Framework