Skip to content

Instantly share code, notes, and snippets.

@bilinin
Last active November 19, 2015 10:53
Show Gist options
  • Save bilinin/0c7aabb24a6f4025a8d0 to your computer and use it in GitHub Desktop.
Save bilinin/0c7aabb24a6f4025a8d0 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>PHP Калькулятор</title>
</head>
<body>
<center>
<?php
$one = $_POST['one'];
$two = $_POST['two'];
$rez = 0;
$fun = $_POST['but'];
switch ($fun) {
case "+":
$rez = $one+$two;
break;
case "-":
$rez = $one-$two;
break;
case "*":
$rez = $one*$two;
break;
case "/":
$rez = $one/$two;
break;
}
echo "Result = ";
echo $rez;
?>
<form action="index.php" method="post">
<p>
One:<input name='one' value="<?php echo $one; ?>">
</p>
<p>
Two:<input name='two' value="<?php echo $two; ?>">
</p>
<p>
<input type="submit" value="+" name="but">
<input type="submit" value="-" name="but">
<input type="submit" value="*" name="but">
<input type="submit" value="/" name="but">
</p>
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment