Measurements can be output in a number of different ways.
Output with unit of measurement
Zend_Measure
supports outputting of strings automatically.
Przykład 21.7. Automatic output
<?php require_once 'Zend/Measure/Length.php'; $locale = new Zend_Locale('de'); $mystring = "1.234.567,89 Meter"; $unit = new Zend_Measure_Length($mystring,Zend_Measure_Length::STANDARD, $locale); echo $unit; ?>
The value of a measurement can be output using getValue()
.
Przykład 21.8. Output a value
<?php require_once 'Zend/Measure/Length.php'; $locale = new Zend_Locale('de'); $mystring = "1.234.567,89 Meter"; $unit = new Zend_Measure_Length($mystring,Zend_Measure_Length::STANDARD, $locale); echo $unit->getValue(); ?>
The function getType()
returns the current unit of measurement.
Przykład 21.9. Outputting units
<?php require_once 'Zend/Measure/Weight.php'; $locale = new Zend_Locale('de'); $mystring = "1.234.567,89"; $unit = new Zend_Measure_Weight($mystring,Zend_Measure_Weight::POUND, $locale); echo $unit->getType(); ?>