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

  • array $args - an array of command-line arguments

  • string $shortoptions - specifies the list of allowed short options. See the "Options" section for more information.

  • array $longoptions - specifies the list of allowed long options. Default is NULL . See the "Options" section for more information.

Return value

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

Throws

Possible PEAR_Error values
Error code Error message Reason Solution
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.

Introduction - Options (Previous) Console_Getopt::readPHPArgv (Next)
Last updated: Tue, 02 Jun 2009 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.