math

1.0 1.1 1.2 1.3

Computes a mathematical equation

<?php
math(string $equation, [ string $format = "", [ string $assign = "", [ array $rest = array() ]]])
  • equation: the equation to compute, it can include normal variables with $foo or special math variables without the dollar sign
  • format: output format, see sprintf() for details
  • assign: if set, the output is assigned into the given variable name instead of being output
  • rest: all math specific variables that you use must be defined, see the example

Examples

Example #1

index.tpl
{$c=2}
{math "(a+b)*$c/4" a=3 b=5} {* which translates to: ((3+5)*2/4) *}

The above example will output:

4