Prev | Current Page 58 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

com>
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
if ($value >= 0) {
$output = $symbol . number_format($value, 2);
} else {
$output = '-' . $symbol . number_format(abs($value), 2);
}
}
return $output;
}
}
(annotation) <#1 Helper function is named using camelCase.>
(annotation) <#2 If $value is not a number, then ignore it.>
#2 shows a security consideration. If we don??™t know that $value is a number, then we do not return it as
part of the output. This helps to ensure that we do not inadvertently introduce an XSS vulnerability.
The name of the function within the helper class is the same as the function that is called within the
template, formatCurrency() in our case. Internally, Zend_View has an implementation of the __call() magic
function to find our helper class and execute the formatCurrency () function. In order to find it though, we need
to register the directory and class prefix with Zend_View using the SetHelperPath member function:
$view->setHelperPath('./Helper', 'ZFiA_View_Helper');
This allows us to have many helper functions within the same directory. The file containing
ZFiA_View_Helper_FormatCurrency must be called FormatCurrency.php and must be in the Helper directory.


Pages:
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
zakłady bukmacherskie ziemme.bizor.pl ścianki biurowe baseny ogrodowe zakłady bukmacherskie