<html>
<! CommandLine.php                                            >
<! Chapter 10, Oracle Database XE PHP Web Programming         >
<! by Michael McLaughlin                                      >
<!                                                            >
<! This script demonstrates how to pass arguments from either >
<! the command-line or web browser URL.                       >
<head>
<title>
  Chapter 10 : CommandLine.php
</title>
</head>
<body>
<?php
  // Run script as command-line script.
  if (@$_SERVER["argv"])
    if ($_SERVER["argc"] > 1)
      for ($i = 1;$i < $_SERVER["argc"];$i++)
        print "Command-line [".($i - 1)."]\t[".$_SERVER["argv"][$i]."]\n";
    else
      print "Command-line arguments are not provided.\n";

  // Run script as URL with GET method that has arguments.
  else if (count($_GET))
    foreach ($_GET as $name => $value)
      print "\$_GET[\"$name\"] = [$value]<br>";

  // Run script as URL with POST method that has arguments.
  else if (count($_POST))
    foreach ($_POST as $name => $value)
      print "\$_POST[\"$name\"][$value]<br>";

  // Run script as URL without arguments.
  else
    print "Browser URL arguments are not provided.<br>";
?>
</body>
</html>