Solar_Getopt::populate()

public void Solar_Getopt::populate ( array $argv = NULL )

Populates the options with values from $argv.

Parameters

  • (array) $argv: The argument values passed on the command line. If empty, will use $_SERVER['argv'] after shifting off its first element.

Returns

  • (void)

Description

Populates the options with values from $argv.

For a given option on the command line, these values will result:

--foo-bar

'foo_bar' => true

--foo-bar=baz

'foo_bar' => 'baz'

--foo-bar="baz dib zim"

'foo_bar' => 'baz dib zim'

-s

's' => true

-s dib

's' => 'dib'

-s "dib zim gir"

's' => 'dib zim gir'

Short-option clusters are parsed as well, so that -fbz will result in array('f' => true, 'b' => true, 'z' => true). Note that you cannot pass parameters to an option in a cluster.

If an option is not defined, an exception will be thrown.

Options values are stored under the option key name, not the short- or long-format version of the option. For example, an option named 'foo-bar' with a short-form of 'f' will be stored under 'foo-bar'. This helps deconflict between long- and short-form aliases.



Local