php - defining the path of an image dynamically -
i've created simple fiunction, not sure whether should using switch/case evaluation, here goes. should take value of field , determine image should utilize , retuen path of image img tag. i've got img tag below calling function, advice on im doing wrong?.
many thanks
function imgtype ($parameter) { if ($paramater) === "t") {$imgsrc = 'images/onetick.gif'; homecoming $imgsrc;} elseif ($parameter === "tt") {$imgsrc = 'images/twotick.gif'; homecoming $imgsrc;} elseif ($parameter === "x") {$imgsrc = 'images/cross.gif'; homecoming $imgsrc;} }
this tag calls function
<img width="29" height="19" src="<?php imgtype($myrecord->getfield('fieldvalue')); ?>">
you have print result:
<img width="29" height="19" src="<?php echo imgtype($myrecord->getfield('fieldvalue')); ?>">
you doing using if
else
statements. suppose faster switch
, more yet if utilize ===
rather ==
, doing.
performance info.
php
No comments:
Post a Comment