Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Add
- */
- if(isset($_POST['add'])) {
- $x = $_POST['x'];
- $y = $_POST['y'];
- if(is_numeric($x) && is_numeric($y)) {
- $answer = $x + $y;
- } else {
- $answer = "Error";
- }
- }
- /*
- * Subtract
- */
- if(isset($_POST['subtract'])) {
- $x = $_POST['x'];
- $y = $_POST['y'];
- if(is_numeric($x) && is_numeric($y)) {
- echo $x + $y;
- $answer = $x - $y;
- } else {
- $answer = "Error";
- }
- }
- /*
- * Multiply
- */
- if(isset($_POST['multiply'])) {
- $x = $_POST['x'];
- $y = $_POST['y'];
- if(is_numeric($x) && is_numeric($y)) {
- $answer = $x * $y;
- } else {
- $answer = "Error";
- }
- }
- /*
- * Divide
- */
- if(isset($_POST['divide'])) {
- $x = $_POST['x'];
- $y = $_POST['y'];
- if($y == 0) {
- $answer = "INF";
- } else if(is_numeric($x) && is_numeric($y)) {
- $answer = $x / $y;
- } else {
- $answer = "Error";
- }
- }
- /*
- * Square
- */
- if(isset($_POST['square'])) {
- $x = $_POST['x'];
- $y = $_POST['y'];
- if(is_numeric($x)) {
- $answer = pow($x, 2);
- } else {
- $answer = "Error";
- }
- }
- /*
- * Power
- */
- if(isset($_POST['power'])) {
- $x = $_POST['x'];
- $y = $_POST['y'];
- if(is_numeric($x) && is_numeric($y)) {
- $answer = pow($x, $y);
- } else {
- $answer = "Error";
- }
- }
- /*
- * Root
- */
- if(isset($_POST['root'])) {
- $x = $_POST['x'];
- // $y = $_POST['y'];
- if(is_numeric($x)) {
- $answer = sqrt($x);
- } else {
- $answer = "Error";
- }
- }
- /*
- * Table
- */
- if(isset($_POST['table'])) {
- $x = $_POST['x'];
- $y = $_POST['y'];
- $tafel = array();
- for($i = 1 ; $i < 11 ; $i++) {
- $aq = $x * $i;
- $tafel[]+=$aq;
- }
- $answer = implode(', ', $tafel);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement