-
-
Save jkuip/43bb6716e0e907f74b49 to your computer and use it in GitHub Desktop.
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Calculator</title> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"> | |
| </head> | |
| <body> | |
| <div class="container" style="margin-top: 50px"> | |
| <?php | |
| // If the submit button has been pressed | |
| if(isset($_POST['submit'])) | |
| { | |
| // Check number values | |
| if(is_numeric($_POST['number1']) && is_numeric($_POST['number2'])) | |
| { | |
| // Calculate total | |
| if($_POST['operation'] == 'plus') | |
| { | |
| $total = $_POST['number1'] + $_POST['number2']; | |
| } | |
| if($_POST['operation'] == 'minus') | |
| { | |
| $total = $_POST['number1'] - $_POST['number2']; | |
| } | |
| if($_POST['operation'] == 'times') | |
| { | |
| $total = $_POST['number1'] * $_POST['number2']; | |
| } | |
| if($_POST['operation'] == 'divided by') | |
| { | |
| $total = $_POST['number1'] / $_POST['number2']; | |
| } | |
| // Print total to the browser | |
| echo "<h1>{$_POST['number1']} {$_POST['operation']} {$_POST['number2']} equals {$total}</h1>"; | |
| } else { | |
| // Print error message to the browser | |
| echo 'Numeric values are required'; | |
| } | |
| } | |
| ?> | |
| <!-- Calculator form --> | |
| <form method="post" action="calculator.php"> | |
| <input name="number1" type="text" class="form-control" style="width: 150px; display: inline" /> | |
| <select name="operation"> | |
| <option value="plus">Plus</option> | |
| <option value="minus">Minus</option> | |
| <option value="times">Times</option> | |
| <option value="divided by">Divided By</option> | |
| </select> | |
| <input name="number2" type="text" class="form-control" style="width: 150px; display: inline" /> | |
| <input name="submit" type="submit" value="Calculate" class="btn btn-primary" /> | |
| </form> | |
| </div> | |
| </body> | |
| </html> |
wow
❤️
sweet
Are you a student, beginner developer, or someone working on an academic PHP project? We’ve compiled a powerful collection of free PHP calculators online – complete with source code. These ready-made tools are perfect for learning PHP, customizing for your own needs, or using directly in websites and applications. Here’s a curated list of our free PHP calculator projects, all available for instant download:
https://www.phpscriptsonline.com/blog/download-free-php-calculators-online
A calculator.php file typically contains server-side logic to process user inputs and perform calculations using PHP. It can handle operations like addition, subtraction, or more complex formulas and return results dynamically on a webpage. For simpler use cases, tools like a assignment grade calculator can also handle calculations quickly without needing backend setup.
A simple PHP calculator is a basic web tool built using PHP that performs arithmetic operations like addition, subtraction, multiplication, and division. It takes user input through an HTML form and processes it on the server side. This makes it useful for learning PHP logic and form handling. Just like a PHP calculator solves math instantly, tools like Calcular Porcentaje make percentage calculations faster and easier for users.
A calculator.php file typically contains server-side logic to process user inputs and perform calculations using PHP. It can handle operations like addition, subtraction, or more complex formulas and return results dynamically on a webpage. For simpler use cases, tools like a Divide any shared expense in seconds. Restaurant bills, travel costs, roommate rent — split fairly every time.
yes