Console_Getopt::getopt

Console_Getopt::getopt -- fetch the command-line options

Synopsis

require_once 'Console/Getopt.php';

array getopt (array $args, string $shortoptions [, array $longoptions = NULL])

Description

Parses the command-line options and returns them.

Parameter

Return value

array - two-element array containing the list of parsed options and the non-option arguments or a PEAR_Error.

Throws

Table 32-1. Possible PEAR_Error values

Error codeError messageReasonSolution
NULL "Console_Getopt: option --$opt is ambiguous" Two or more long options starts with the same character. Change the naming of the options. It is also possible that the error is caused by a typing mistake.
NULL "Console_Getopt: option --$opt requires an argument" No parameter for a option was given. Normally this is a user mistake. If the parameter is optional, you have to markup the parameter as optional in the option definitions.
NULL "Console_Getopt: option --$opt doesn't allow an argument" A parameter for a option was given. Normally this is a user mistake. If the option requires a (optional) parameter, you have to markup it in the options definition.
NULL "Console_Getopt: unrecognized option --$opt" Unknown option. Normally this is a user mistake. If the option exists, you have to define them in the options definition.

Note

This function can not be called statically.