本文整理汇总了PHP中CLI::_init方法的典型用法代码示例。如果您正苦于以下问题:PHP CLI::_init方法的具体用法?PHP CLI::_init怎么用?PHP CLI::_init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLI
的用法示例。
在下文中一共展示了CLI::_init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseCommand
* I tried to use getopt but had it fail occasionally to find any
* but argc has always had our back. We don't have all of the "power"
* of getopt but this does us just fine.
*/
protected static function parseCommand()
{
$options_found = false;
for ($i = 1; $i < $_SERVER['argc']; $i++) {
// If there's no '-' at the beginning of the argument
// then add it to our segments.
if (!$options_found && strpos($_SERVER['argv'][$i], '-') === false) {
self::$segments[] = $_SERVER['argv'][$i];
continue;
}
$options_found = true;
if (substr($_SERVER['argv'][$i], 0, 1) != '-') {
continue;
}
$arg = str_replace('-', '', $_SERVER['argv'][$i]);
$value = null;
// If the next item starts with a dash it's a value
if (isset($_SERVER['argv'][$i + 1]) && substr($_SERVER['argv'][$i + 1], 0, 1) != '-') {
$value = $_SERVER['argv'][$i + 1];
$i++;
}
self::$options[$arg] = $value;
}
}
}
CLI::_init();