本文整理匯總了PHP中Shell::arg方法的典型用法代碼示例。如果您正苦於以下問題:PHP Shell::arg方法的具體用法?PHP Shell::arg怎麽用?PHP Shell::arg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Shell
的用法示例。
在下文中一共展示了Shell::arg方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
public function render()
{
switch ($this->mode) {
case Shell::SHELL_SAFE:
return $this->argument;
case Shell::SHELL_ARG_MULTIPLE:
$ret = '';
if (isset($this->value)) {
$sub_conf = isset($this->conf['each']) ? $this->conf['each'] : array('mode' => NULL, 'delimiter' => NULL);
$sub_type = $sub_conf['mode'];
foreach ((array) $this->value as $part) {
$sub = Shell::arg($this->argument, $sub_type, $part, $sub_conf);
$tmp = $sub->render();
if ($tmp != '') {
$ret .= ' ' . $tmp;
}
}
}
return $ret;
case Shell::SHELL_OPTIONS:
$output = '';
foreach ($this->value as $opt) {
$tmp = Shell::arg($opt['name'], $opt['mode'] ? $opt['mode'] : Shell::SHELL_ARG_BASIC, $opt['value'], $opt)->render();
if ($tmp !== '') {
$output .= ' ' . $tmp;
}
}
return $output;
case Shell::SHELL_ARG_BOOL_DBL:
if ($this->value) {
return escapeshellarg('--' . $this->argument);
}
return '';
case Shell::SHELL_ARG_BOOL_SGL:
if ($this->value) {
return escapeshellarg('-' . $this->argument);
}
return '';
case Shell::SHELL_ARG_BASIC_DBL:
if (isset($this->value)) {
return escapeshellarg('--' . $this->argument . '=' . $this->value);
}
return '';
case Shell::SHELL_ARG_BASIC_DBL_NOEQUAL:
if (isset($this->value)) {
return escapeshellarg('--' . $this->argument) . ' ' . escapeshellarg($this->value);
}
return '';
case Shell::SHELL_ARG_PAIR_DBL_NOEQUAL:
if (isset($this->value)) {
$ret = escapeshellarg('--' . $this->argument);
$delim = isset($this->conf['delimiter']) ? $this->conf['delimiter'] : ':';
$parts = explode($delim, $this->value, 2);
foreach ($parts as $part) {
$ret .= ' ' . escapeshellarg($part);
}
return $ret;
}
return '';
case Shell::SHELL_ARG_BASIC_SGL:
if (isset($this->value)) {
return escapeshellarg('-' . $this->argument) . ' ' . escapeshellarg($this->value);
}
return '';
case Shell::SHELL_STDERR:
return '2>' . escapeshellarg($this->value);
case Shell::SHELL_ARG_BASIC:
default:
return escapeshellarg($this->argument);
}
}