20.2. Parsing Program Arguments20.2.2. SolutionLook in $_SERVER['argc'] for the number of arguments and $_SERVER['argv'] for their values. The first argument, $_SERVER['argv'][0], is the name of script that is being run:
20.2.3. DiscussionIn order to set options based on flags passed from the command line, loop through $_SERVER['argv'] from 1 to $_SERVER['argc']:
In this example, the -v and -q arguments are flags that set $verbose and $quiet, but the -c argument is expected to be followed by a string. This string is assigned to $config_file. 20.2.4. See AlsoRecipe 20.3 for more parsing arguments with getopt; documentation on $_SERVER['argc'] and $_SERVER['argv'] at http://www.php.net/reserved.variables.
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|