Calc Test Page: Difference between revisions
No edit summary |
(More documentation) |
||
Line 5: | Line 5: | ||
< | <nowiki>#vardefine creates the variable & gives it a value. | ||
</nowiki><br><nowiki> #var allows you to use it. you need to use it like {{#var:X}} | |||
</nowiki><br><nowiki> {{#var:X}} by itself will print the value of the var | |||
</nowiki><br><nowiki> To do a calculation you need to use {{#expr:equation}} - this will also print the value of the expression. | |||
</nowiki><br><nowiki> Check the source of the page for examples. | |||
</nowiki> <br> | |||
Latest revision as of 16:04, 17 November 2022
Sample code test Calc e^43 = 4.7278394682294E+18
Simple Math test Calc2 2*3 = 6
#vardefine creates the variable & gives it a value.
#var allows you to use it. you need to use it like {{#var:X}}
{{#var:X}} by itself will print the value of the var
To do a calculation you need to use {{#expr:equation}} - this will also print the value of the expression.
Check the source of the page for examples.
Using Variables test calc 6
15
This is PHP code for a calculator
<?php if(isset($_POST['sub'])){ $num1=$_POST['n1']; $num2=$_POST['n2']; $oprnd=$_POST['sub']; if($oprnd=="+") $ans=$num1+$num2; else if($oprnd=="-") $ans=$num1-$num2; else if($oprnd=="x") $ans=$num1*$num2; else if($oprnd=="/") $ans=$num1/$num2; }?>
Links to useful pages
https://t4tutorials.com/simple-calculator-using-php/
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions
https://www.mediawiki.org/wiki/Extension:Variables