Skip to content

Flags

Options that take no value.

An option uses the next token as its value when that token does not start with -. A flag is an option that takes no value. Give the flag names, without dashes, in the second parameter of parse(). The flags apply only to that call.

// php test.php --dev build
$parser->parse($argv);          // ['dev' => 'build']
$parser->parse($argv, ['dev']); // ['dev' => true, 0 => 'build']

// php test.php -vo out.txt
$parser->parse($argv);          // ['v' => 'out.txt', 'o' => 'out.txt']
$parser->parse($argv, ['v']);   // ['v' => true, 'o' => 'out.txt']

An option with an equal sign keeps its value, also when it is a flag: --dev=yes gives ['dev' => 'yes'].

Navigation

Type to search…

↑↓ navigate↵ selectEsc close