$val) { if ($key != "equation" && $key != "format" && $key != "assign") { // make sure value is not empty if (strlen($val)==0) { throw new Template_Exception("math: parameter $key is empty", $template_object); return; } if (!is_numeric($val)) { throw new Template_Exception("math: parameter $key: is not numeric", $template_object); return; } $equation = preg_replace("/\b$key\b/",$val, $equation); } } eval("\$template_object_math_result = ".$equation.";"); if (empty($params['format'])) { if (empty($params['assign'])) { return $template_object_math_result; } else { $template_object->assign($params['assign'],$template_object_math_result); } } else { if (empty($params['assign'])) { printf($params['format'],$template_object_math_result); } else { $template_object->assign($params['assign'],sprintf($params['format'],$template_object_math_result)); } } } ?>