php - pcntl_fork() 返回, fatal error : Call to undefined function pcntl_fork()

标签 php fork command-line-interface pcntl undefined-function

我正在尝试使用 pcntl_fork() 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);
}

我得到:

Fatal error: Call to undefined function pcntl_fork()

谁能建议如何解决这个问题?

最佳答案

当 PHP 用作 Apache 模块(例如 XAMPP)时,不能使用函数 'pcntl_fork'。您只能在 CGI 模式或命令行中使用 pcntl_fork。

使用该函数会导致:' fatal error :调用未定义函数:pcntl_fork()'

来源:http://php.net/manual/en/function.pcntl-fork.php

关于php - pcntl_fork() 返回, fatal error : Call to undefined function pcntl_fork(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16826530/

相关文章:

PHP:Facebook/Twitter 集成

php - json、ajax、php和mySQL的设计结构

fork - 并行进程的数量将如何影响 CPU 的性能?

c - 程序试图实现的输出是什么

c - 将数据与用户输入分开。

php - 单个 php,同时包含三种不同类别的图像

php - 检查一个数组中某个键的值是否等于另一个数组中不同键的值

C中的并发进程

android - 手动将 Cordova (Phonegap) 插件添加到现有的 android 项目

node.js - 带有 command.js 的未命名参数