1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php // $ pear size -t doc,php -v pear_size require_once 'Console/Getopt.php'; $cg = new Console_Getopt(); $args = $cg->readPHPArgv(); array_shift($args); $shortOpts = 't:v'; $longOpts = array('type=', 'verbose'); $params = $cg->getopt2($args, $shortOpts, $longOpts); if (PEAR::isError($params)) { echo 'Error: ' . $params->getMessage() . "\n"; exit(1); } var_dump($params); ?> |
$ php console-getopt-14684.php -t doc,php -v pear_size array(2) { [0] => array(2) { [0] => array(2) { [0] => string(1) "t" [1] => string(7) "doc,php" } [1] => array(2) { [0] => string(1) "v" [1] => NULL } } [1] => array(1) { [0] => string(9) "pear_size" } }
php console-getopt-14684.php -t doc,php -v pear_size array(2) { [0]=> array(2) { [0]=> array(2) { [0]=> string(1) "t" [1]=> string(7) "doc,php" } [1]=> array(2) { [0]=> string(1) "v" [1]=> NULL } } [1]=> array(1) { [0]=> string(9) "pear_size" } }