Наш чат в Telegram для обмена идеями, проектами, мыслями, людьми в сфере ИТ г.Ростова-на-Дону: @it_rostov

getopt

(PHP 4 >= 4.3.0, PHP 5)

getopt — Gets options from the command line argument list


Описание

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

Parses options passed to the script.


Список параметров

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.

The options parameter may contain the following elements:

  • Individual characters (do not accept values)
  • Characters followed by a colon (parameter requires value)
  • Characters followed by two colons (optional value)
Option values are the first argument after the string. It does not matter if a value has leading white space or not.

Замечание: Optional values do not accept " " (space) as a separator.

Замечание:

The format for the options and longopts is almost the same, the only difference is that longopts takes an array of options (where each element is the option) where as options takes a string (where each character is the option).


Возвращаемые значения

This function will return an array of option / argument pairs or FALSE on failure.

Замечание:

The parsing of options will end at the first non-option found, anything that follows is discarded.




Смотрите также:
Описание на ru2.php.net
Описание на php.ru