Test file

back to index

math

numeric comparison

Apache comparison is normally string comparison, so 20 > 100, this is numeric comparison to counter that.

Directives

  1. <!--#func var="fred" func="cmp" a="-1" op="eq" b="2" --><!--#echo var="fred" -->
  2. <!--#func var="fred" func="cmp" a="-1" op="ne" b="2" --><!--#echo var="fred" -->
  3. <!--#func var="fred" func="cmp" a="-1" op="lt" b="2" --><!--#echo var="fred" -->
  4. <!--#func var="fred" func="cmp" a="-1" op="gt" b="2" --><!--#echo var="fred" -->
  5. <!--#func var="fred" func="cmp" a="-1" op="le" b="2" --><!--#echo var="fred" -->
  6. <!--#func var="fred" func="cmp" a="-1" op="ge" b="2" --><!--#echo var="fred" -->

Results

  1. 0
  2. 1
  3. 1
  4. 0
  5. 1
  6. 0

Negative of a value

Directive

<!--#func var="fred" func="neg" value="-1" --><!--#echo var="fred" -->

Result

1

Multiplication

Directive

<!--#func var="fred" func="mult" value="-16" value="-3" --><!--#echo var="fred" -->

Result

48

Division

Only gives whole number results

Directive

<!--#func var="fred" func="div" value="-16" value="3" --><!--#echo var="fred" -->

Result

-5

Modulo Division

Gives the remainder of the division

Directive

<!--#func var="fred" func="mod" value="30" value="-16" --><!--#echo var="fred" -->

Result

14

Numeric Addition

Directive

<!--#func var="fred" func="add" value="-16" value="3" --><!--#echo var="fred" -->

Result

-13