本文整理汇总了PHP中Executor::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP Executor::exec方法的具体用法?PHP Executor::exec怎么用?PHP Executor::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Executor
的用法示例。
在下文中一共展示了Executor::exec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _exec
/**
* @param array
* @param array
* @param array
* @return int
* */
public function _exec(array $argv, array $envp, array $redirections)
{
$descriptors = $this->descriptors;
foreach ($redirections as $n => $redirection) {
if (is_array($redirection)) {
if (($handle = @fopen($redirection[1], $redirection[0])) === FALSE) {
throw new Error('cannot open file ' . $redirection[1]);
}
$descriptors[$n] = $handle;
} else {
assert(is_int($redirection));
if (!isset($descriptors[$redirection])) {
throw new Error('bad file descriptor ' . $redirection);
}
$descriptors[$n] = $descriptors[$redirection];
}
}
// BREAK
if ($argv[0] === 'break') {
$n = 1;
if (isset($argv[1])) {
$n = intval($argv[1]);
}
throw new BuiltinBreak($n);
// COLON
} else {
if ($argv[0] === ':') {
$this->variables['?'] = 0;
} else {
if ($argv[0] === 'continue') {
$n = 1;
if (isset($argv[1])) {
$n = intval($argv[1]);
}
throw new BuiltinContinue($n);
// DOT
} else {
if ($argv[0] === '.') {
if (!(isset($argv[1]) && ($contents = file_get_contents($argv[1])) !== FALSE)) {
if (!isset($argv[1])) {
throw new Error('.: no file given');
} else {
throw new Error('.: cannot read file');
}
}
$saved_can_read = $this->can_read;
$this->can_read = FALSE;
$saved_tokens = $this->tokens;
$this->tokens = $this->tokenize($contents);
$saved_descriptors = $this->descriptors;
$this->descriptors = $descriptors;
try {
$this->interpretMoreCommands();
} catch (BuiltinReturn $r) {
$this->variables['?'] = $r->getExitStatus();
}
$this->can_read = $saved_can_read;
$this->tokens = $saved_tokens;
$this->descriptors = $saved_descriptors;
// EVAL
} else {
if ($argv[0] === 'eval') {
$newtokens = $this->tokenize(implode(' ', array_slice($argv, 1)));
if (end($newtokens) === ';') {
array_pop($newtokens);
}
$this->tokens = array_merge(array(';'), $newtokens, $this->tokens);
// EXEC
} else {
if ($argv[0] === 'exec') {
if (count($argv) > 1) {
fwrite($descriptors[2], "exec: only file descriptors handling implemented\n");
$this->variables['?'] = 255;
} else {
$this->descriptors = $descriptors;
$this->variables['?'] = 0;
}
// EXIT
} else {
if ($argv[0] === 'exit') {
$n = 0;
if (isset($argv[1])) {
$n = intval($argv[1]);
}
throw new BuiltinExit($n);
// EXPORT
} else {
if ($argv[0] === 'export') {
if (isset($argv[1]) && $argv[1] === '-p') {
foreach ($this->exported as $exported => $_) {
if (isset($this->variables[$exported])) {
fprintf($descriptors[1], "export %s='%s'\n", $exported, $this->variables[$exported]);
} else {
fprintf($descriptors[1], "export %s\n", $exported);
//.........这里部分代码省略.........