使用命令:
$output = shell_exec("/usr/bin/php /path/to/my/file.php");
echo $output;
得到这个结果:
string(1208) "Content-type: text/html string(1165) "Content-type: text/html string(1122) "Content-type: text/html string(1079) "Content-type: text/html string(1036) "Content-type: text/html string(994) "Content-type: text/html string(952) "Content-type: text/html string(910) "Content-type: text/html string(868) "Content-type: text/html string(826) "Content-type: text/html string(784) "Content-type: text/html string(742) "Content-type: text/html string(700) "Content-type: text/html string(658) "Content-type: text/html string(616) "Content-type: text/html string(574) "Content-type: text/html string(532) "Content-type: text/html string(490) "Content-type: text/html string(448) "Content-type: text/html string(406) "Content-type: text/html string(364) "Content-type: text/html string(322) "Content-type: text/html string(280) "Content-type: text/html
Warning: shell_exec() [function.shell-exec]: Unable to execute '/usr/bin/php /home/zumblemo/public_html/ad/../test.php' in /home/zumblemo/public_html/ad/test.php on line 5
bool(false) " " " " " " " " " " " " " "
它现在应该只输出单词“Test”。
我不明白。当我像这样启动 Python 文件时,它可以工作。
托管支持说这同样适用于 PHP 文件。
路径是 100% 正确的(当它们不正确时 - 它只是给出 NULL 结果,就像它应该的那样)
PS:太好了!php-cli 工作。谢谢!