<?php
session_start();
// we will be sending XML
header('Content-Type: text/xml');
// Simulated stock ticker. Uses a session to keep track of the current 
// price, changes by a small random value each time called.
$max = 30;
$min = 10;
$step = 1;
$lastprice = $_SESSION['lastprice'];

if (! $lastprice) {
  // first time - initialize to the midpoint
  $lastprice = ($min+$max)/2;
} 
// generate a new price
$newprice = $lastprice + rand(-$step,$step);

$_SESSION['lastprice'] = $newprice;

// send back content
echo "<quote>
  <price>$newprice</price>
</quote>\n";
?>