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

Creating measurements from strings

Many measurements received as input to Zend Framework applications can only be passed to Zend_Measure_* classes as strings, such as numbers written using roman numerals or extremely large binary values that exceed the precision of PHP's native integer and float types. Since integers can be denoted using strings, if there is any risk of losing precision due to limitations of PHP's native integer and float types, using strings instead. Zend_Measure_Number uses the BCMath extension to support arbitrary precision, as shown in the example below, to avoid limitations in many PHP functions, such as bin2dec().

Example 609. Creation using strings

$unit = new Zend_Measure_Number($mystringZend_Measure_Number::BINARY);


Zend Framework