getopt 函数用法

array getopt ( string $options [, array $longopts ] )

options
Each character in this string will be used as option characters and matched against options passed to the script starting with a single hyphen (-). For example, an option string "x" recognizes an option -x. Only a-z, A-Z and 0-9 are allowed.
longopts

An array of options. Each element in this array will be used as option strings and matched against options passed to the script starting with two hyphens (--). For example, an longopts element "opt" recognizes an option --opt.

$options中的每个字符与选项字符相对应。

比如一个选项字符"a"对应一个选项"-a"。

注意:选项字符只能是 a-z 和 0-9,不能为空格。

$longopts中的每一个元素对应一个选项。

比如一个元素"usrid"对应一个选项"--usrid"。

$shortopt = '';
$longopt = array('application_path:');
$options = getopt($shortopt, $longopt);
var_dump($options);

array(1) {
  ["application_path"]=>
  string(8) "/var/www"
}


你可能感兴趣的:(getopt)