Calc Test Page: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(updated with instructions in comments.) |
||
Line 7: | Line 7: | ||
<!-- | <!-- | ||
#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. | |||
--> | --> | ||
<br> | <br> | ||
{{#vardefine:X|2}} | {{#vardefine:X|2}} | ||
Line 18: | Line 20: | ||
{{#vardefine:Y|3}} | {{#vardefine:Y|3}} | ||
<br> | <br> | ||
<br>'''Using Variables test | <br>'''Using Variables test calc''' {{#expr:{{#var:X}}*{{#var:Y}}}} | ||
<br> | <br> | ||
{{#vardefine:a|3 }} | {{#vardefine:a|3 }} | ||
{{#vardefine:b|9 }} | {{#vardefine:b|9 }}xxx | ||
{{# | {{#vardefine:x|{{#expr:2*{{#var:a}}+{{#var:b}}}}}}<br>xxx | ||
{{#var:x}} | |||
<!-- Random php code test --> | <!-- Random php code test --> | ||
<br> | <br> |
Revision as of 15:49, 17 November 2022
Sample code test Calc e^43 = 4.7278394682294E+18
Simple Math test Calc2 2*3 = 6
Using Variables test calc 6
xxx
xxx
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