ConFoo Montreal 2026: Call for Papers

Voting

: min(two, eight)?
(Example: nine)

The Note You're Voting On

php at keith tyler dot com
1 year ago
Note that if you are mangling $argv separate from getopt(), that getopt() expects $argv to start with the command name in $argv[0]. So if you've shifted $argv, getopt() will start parsing at the second token, which means it will either miss the first option, or start parsing on the first option's value, breaking parsing.

$cmd = array_shift($argv);

$key_id=array_shift($argv);

array_unshift($argv,"");

$opts = getopt("a:b:c:");

getopt() skips over $argv[0] to start its parsing at $argv[1]. It doesn't really matter what is in $argv[0].

<< Back to user notes page

To Top