Heres how i'd do it,
<?php
// X and Y are imported variables, and z is the operator, d division, m multiply, s subtract, a add.
// Set the gets to plain variables
$x = $_GET['x'];
$y = $_GET['y'];
$z = $_GET['z'];
// Switch to do the operation
switch ($z) {
case 'a':
$answer = $x+$y;
$operator = '+';
break;
case 's':
$answer = $x-$y;
$operator = '-';
break;
case 'd':
$answer = $x/$y;
$operator = '/';
break;
case 'm':
$answer = $x*$y;
$operator = '*';
break;
default:
echo "No operator supplied, defaulting to addition...\n";
$answer = $x+$y;
break;
}
echo "The solution to the problem, {$x}{$operator}{$y} is, {$answer}";
?>
Problly not living up to the spirit of the challenge, but this is how i'd do it.
Just call the script like this, page.php?x=1&y=1&z=a (that will add 1 and 1)
You could also change the $GET to $POST and use a form to run the script.