|
|
(Next) Console_Getopt::getopt |
||||
| |
|||||
|
|||||
Getopt() supports two types of options: short options and long options
Calling a script with short and long options
# Using short optionsmyphpscript -q -l en -o
# Using long options insteadmyphpscript --quite --lang=en --option
# Mixing bothmyphpscript -q --lang=en -o
<?php
$shortoptions = "qlo";
?>
<?php
$shortoptions = "ql:o::";
?>
The long options work equally, but they have to be defined in an array:
<?php
$longoptions = array("quite", "lang", "option");
?>
<?php
$longoptions = array("quite", "lang=", "option==");
?>
The return value is an array of two elements: the list of parsed options and the list of non-option command-line arguments. Each entry in the list of parsed options is a pair of elements - the first one specifies the option, and the second one specifies the option argument, if there was one, else the value is NULL.
|
|
(Next) Console_Getopt::getopt |
||||||||
| |
|||||||||
|
|||||||||