PhpRiot
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

Compare

To determine if a measurement is less than or greater than another, use compare(), which returns 0, -1 or 1 depending on the difference between the two objects. Identical measurements will return 0. Lesser ones will return a negative, greater ones a positive value.

Example 619. Difference

<?php
$unit 
= new Zend_Measure_Length(100Zend_Measure_Length::CENTIMETER);
$unit2 = new Zend_Measure_Length(1Zend_Measure_Length::METER);
$unit3 = new Zend_Measure_Length(1.2Zend_Measure_Length::METER);

print 
"Equal:".$unit2->compare($unit);
print 
"Lesser:".$unit2->compare($unit3);
print 
"Greater:".$unit3->compare($unit2);


Zend Framework