PHP uses getopt () to parse cli parameters, getoptcli
The getopt () in the PHP manual is described as follows:
/**
* Gets options from the command line argument list
* @ Link http://php.net/manual/en/function.getopt.php
* @ Param string $ 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
* Option-x.
* Only a-z, A-Z and 0-9 are allowed.
* @ Param array $ longopts [optional] An array of options. Each element in this array will be used as option
* Strings and matched against options passed to the script starting
* Two hyphens (--).
* For example, an longopts element "opt" recognizes
* Option -- opt.
* Prior to PHP5.3.0 this parameter was only available on few systems
* @ Param int $ optind If the optind parameter is present, then the index where argument parsing stopped will be written to this variable.
* @ Return array This function will return an array of option/argument pairs or false on
* Failure.
* @ Since 4.3.0
* @ Since 5.0
*/
Function getopt ($ options, array $ longopts = null, & $ optind = null ){}
$ Options: String type. Each character is used as an option character. The option that matches the input script starts with a single hyphen. For example, an option string "x" identifies an option-x. Only a-z, A-Z, and 0-9 are allowed.
The character parameters can be followed:
$ Longopts: Array type. Each element in this array is used as an option string and matches the options passed into the script with two hyphens. For example, the long option element "opt" identifies an option -- opt.
$ OptionsAnd$ LongoptsThe format is almost the same. The only difference is that$ LongoptsIt must be an array of options (each element is an option), while$ OptionsA string is required (each character is an option ).