Win*_*ges 1 php requirements pcntl
我编写简单的需求检查脚本.它会检查所有安装的必需PHP模块.我需要检查是否安装了pcntl.但是这个模块只能在cgi环境中访问,对于Web查询是不可见的.extension_loaded('pcntl')和function_exists('pcntl_fork')都返回false.我该如何执行此检查?
The*_*JAG 12
php -i | grep pcntl如果启用了 pcntl,运行将返回以下内容。
pcntl
Run Code Online (Sandbox Code Playgroud)
pcntl support => enabled
Jac*_* M. 10
如果已安装,则返回代码 true
var_dump (extension_loaded('pcntl'));
Run Code Online (Sandbox Code Playgroud)
创建一个名为 cli_supports.php 的文件
<?php
$supports = array();
if (function_exists("pcntl_fork")) $supports[] = "pcntl";
echo implode(",", $supports);
?>
Run Code Online (Sandbox Code Playgroud)
然后从你的特征检测脚本中进行。
$cli_features = explode(",", shell_exec("/usr/local/bin/php ".escapeshellarg(_DIR_."/cli_supports.php")));
Run Code Online (Sandbox Code Playgroud)