<?php
// test.php
 
echo "<form action='test.php' method='get'>";
echo "試著輸入一個參數<input type='text' value='3' name='N' />";
echo "<br><input type='submit' />";
echo "</form>";
 
if(isset($_GET['N']))
{
  $N = $_GET['N'];
 
  // execute R script from shell
  // this will save a plot at temp.png to the filesystem
  exec("Rscript my_rscript.R $N");
 
  // return image tag
  $nocache = rand();
  echo("<img src='temp.png?$nocache' />");
}
?>
