Académique Documents
Professionnel Documents
Culture Documents
In this document a number of PHP programs have been provided to introduce the reader to the
PHP language.
Calculator.html
<html>
<head>
<title>Calculator</title>
</head>
<body>
</form>
</body>
</html>
Calculator.php
<html>
<head>
<title>Calculator-Results</title>
</head>
<body>
<?php
// Simple Calculator Program
// Author: Paul Walcott 02/11/05
//
// This program adds, subtracts, multiplies or divides two
// numbers that has been submitted from the form in the
// file calc.html
//
// This program has not been written for efficiency,
// it merely serves
// as an example of the use of PHP program structures
$input1 = $_REQUEST['i1'];
$input2 = $_REQUEST['i2'];
$add = $_REQUEST['Add'];
$subtract = $_REQUEST['Subtract'];
$multiply = $_REQUEST['Multiply'];
$divide = $_REQUEST['Divide'];
if ($add == "Add")
{
// no validation is being done here
// output all the text between the print statement and "END"
END;
?>
</body>
</html>