CSci 1101: First php examples.

Passing input to a php program


<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Examples of PHP variables and their use
Author: Elena Machkasova elenam@morris.umn.edu
Last modified: 9/24/06
-->

<html>
<head>
<title>
Examples of PHP variables and their use
</title>
<?php 
$n = $_GET["input1"];
$m = $_GET["input2"];
?>
</head>
<body>
<h2>This page tests PHP variables</h2>

<p>
<?php
// integers and what you can do with them
$sum = $n + $m;

// variables are a part of the string that gets printed
print "$n + $m = $sum<br/>\n";

$prod = $n * $m;
$div = $n / $m;
$remainder = $n % $m;
print "$n * $m = $prod<br/>\n $n / $m = $div<br/>\n $n % $m = $remainder<br/>\n";

// changing $n:
$n = $m + 1;
// using \ to print $
print "\$n = $n<br/>\n";
?>
</p>
</body>

</html>

http://rynite.morris.umn.edu/~elenam/1101_spring07/first/input.php?input1=5&input2=3
http://rynite.morris.umn.edu/~elenam/1101_spring07/first/input.php?input1=-1&input2=5


This page is a part of CSci 1101 course web site.