警告:exec() [function.exec]:无法在共享主机上分叉


Warning: exec() [function.exec]: Unable to fork on shared hosting

我使用共享主机Go-daddy服务器我无法在服务器上运行此命令行

警告:system() [function.system]:无法分叉 [ls -lart]

给我运行脚本的想法。

提前谢谢。

共享主机系统出于安全原因禁用某些命令,您需要解决此问题,使用本机PHP进行要执行的操作,打开目录并使用PHP本身读取其内容。

systemexec通常完全禁用或部分受限。

如果您有兴趣,这里有一个简单的代码来获取目录内容:

if (is_dir($base) && is_readable($base)) {
    if ($handle = opendir($base)) {
        $base .= '/';
        while (false !== ($entry = readdir($handle))) {
            //$entry is a file or directory including `.` and `..`
        }
        closedir($handle);
    }
}