CSci 1101: Input to a php program via extended URL.

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: 2/18/08

<html xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
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";



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.