當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Console_Getopt::doGetopt方法代碼示例

本文整理匯總了PHP中Console_Getopt::doGetopt方法的典型用法代碼示例。如果您正苦於以下問題:PHP Console_Getopt::doGetopt方法的具體用法?PHP Console_Getopt::doGetopt怎麽用?PHP Console_Getopt::doGetopt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Console_Getopt的用法示例。


在下文中一共展示了Console_Getopt::doGetopt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getopt

 /**
  * Gets the options and parameters from the command arguments
  *
  * Extracts the command arguments. Tidies the options.
  * Builds the help/usage text.
  *
  * @param  array   $config      the command configuration
  * @param  boolean $toLongNames Converts options names to long names if true,
  *                              e.g. "align", or to short names if false,
  *                              e.g. "A", default is true
  * @param  boolean $asKeys      return options with the names used as array
  *                              keys if true, or leave them as returned by
  *                              Console_Getopt::doGetopt(), default is true
  * @param  integer $version     Console_Getopt::doGetopt version
  * @return array   the options and parameters
  * @access public
  * @static
  */
 public static function getopt($config = array(), $toLongNames = true, $asKeys = true, $version = 2)
 {
     $getopt = new self();
     // silently ignore invalid configuration arrays, defaults the absent ones to empty arrays
     $default = array_combine($getopt->configKeys, array_fill(0, count($getopt->configKeys), array()));
     $config = array_intersect_key($config, $default);
     $config = array_merge($default, $config);
     // extracts the command arguments, including the command name
     $args = Console_Getopt::readPHPArgv();
     $command = array_shift($args);
     // tidies the options, sets the short and long options, and calls getopt
     $config['options'] = $getopt->tidyOptions($config['options']);
     $options = Console_Getopt::doGetopt($version, $args, $getopt->shortOptions, $getopt->longOptions);
     // a syntax error, prints out the error message
     PEAR::isError($options) and exit($options->getMessage());
     // tidies the arguments
     $options[0] = $getopt->tidyArgs($options[0], $toLongNames, $asKeys);
     // a request for help/usage, prints the command usage
     $options[0] == 'help' and exit(implode("\n", $getopt->setHelp($config, $command)));
     return $options;
 }
開發者ID:ookwudili,項目名稱:chisimba,代碼行數:39,代碼來源:GetoptPlus.php

示例2: getopt

 /**
  * This function expects $args to start with the script name (POSIX-style).
  * Preserved for backwards compatibility.
  * @see getopt2()
  */
 function getopt($args, $short_options, $long_options = null)
 {
     return Console_Getopt::doGetopt(1, $args, $short_options, $long_options);
 }
開發者ID:BackupTheBerlios,項目名稱:rheinaufcms-svn,代碼行數:9,代碼來源:Getopt.php

示例3: getopt

 /**
  * This function expects $args to start with the script name (POSIX-style).
  * Preserved for backwards compatibility.
  *
  * @param array  $args          an array of command-line arguments
  * @param string $short_options specifies the list of allowed short options
  * @param array  $long_options  specifies the list of allowed long options
  *
  * @see getopt2()
  * @return array two-element array containing the list of parsed options and
  * the non-option arguments
  */
 function getopt($args, $short_options, $long_options = null, $skip_unknown = false)
 {
     return Console_Getopt::doGetopt(1, $args, $short_options, $long_options, $skip_unknown);
 }
開發者ID:rrsc,項目名稱:freemed,代碼行數:16,代碼來源:Getopt.php


注:本文中的Console_Getopt::doGetopt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。