It's better when it's simple

User Tools

Site Tools


Calc Plugin

Compatible with DokuWiki


plugin Petite calculatrice / Lil calculator

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with calculation, math



  • calc:[your_math_expression]= → result
  • calc:[your_math_expression]>= → your_math_expression = result


  • calc:2+3*5= → 17
  • calc:-1234.56*78.9= → -9,629.568
  • calc:sin(pi()/4)= → 0.707106781187
  • calc:round(exp(1),3)= → 2.718
  • calc:(1+sqrt(5))/2= → 1.61803398875
  • You can display the expression before the result adding a “>” before the “=”
    • calc:2+3*5>= → 2+3*5 = 17
  • The plugin handles errors
    • calc:5/0= → “Calc error: Division by zero”
    • calc:sqrt(-1)= → “Bad value…”
    • calc:unauthorized_function(12)= → “Calc error: syntax error, unexpected ';'”


  • You can customize your decimal and thousand separators in the lang/xx/lang.php file (xx is your language code: fr, en…).
  • A comment is added in the source code of the page before the calculation: you can see what expression has really been processed by the plugin.
  • You can also use this plugin to format a single number. Ex: calc:1234567890= → 1,234,567,890.


  • This plugin uses the PHP eval() function, but it removes all functions that are not mathematical functions before doing the eval().
  • It also removes every “;” and “$” char before doing the evaluation.
  • Tell me if you see a security break using this plugin.

Version history

  • 2008-09-08: first one!
  • 2008-09-10: doesn't try to format string results (like those sent by base_convert)
  • 2008-09-11: prevents XSS


  • Tell me…

I dreamed about it, and you made it. Thank you so much ! fab

You're welcome ;-)

I get an error: Parse error: syntax error, unexpected '{' in /dokuwiki/lib/plugins/calc/syntax.php on line 118:-(

Works like a charm. Thank you so much. Henning

plugin/calc.txt · Last modified: 2010-11-03 09:27 by