This is how I handle arguments with getopt: I use switch within a foreach at the beginning of a program.
<?php
$opts = getopt('hs:');
// Handle command line arguments
foreach (array_keys($opts) as $opt) switch ($opt) {
case 's':
// Do something with s parameter
$something = $opts['s'];
break;
case 'h':
print_help_message();
exit(1);
}
print "$something\n";
?>