Ben*_*rce 19 php fork command-line-interface pcntl undefined-function
我正在尝试使用pcntl_fork()分叉命令行运行XAMPP php进程.当我运行以下命令时:
$pid = pcntl_fork();
if($pid == -1){
file_put_contents('testlog.log',"\r\nFork Test",FILE_APPEND);
return 1; //error
}
else if($pid){
return 0; //success
}
else{
file_put_contents($log, 'Running...', FILE_APPEND);
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
Fatal error: Call to undefined function pcntl_fork()
Run Code Online (Sandbox Code Playgroud)
谁能建议如何解决这个问题?
小智 29
当PHP用作Apache模块(例如XAMPP)时,不可能使用函数'pcntl_fork'.您只能在CGI模式或命令行中使用pcntl_fork.
使用此函数将导致:'致命错误:调用未定义的函数:pcntl_fork()'
资料来源:http://php.net/manual/en/function.pcntl-fork.php