CSci 1101: First php examples.

Passing input to a php program

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Examples of PHP variables and their use
Author: Elena Machkasova
Last modified: 9/24/06

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

// 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";


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

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.