编译一个.php文件,该文件从另一个 php 文件中获取 4 个参数


Compile a .php file which takes in 4 parameter from another php file?

>我有一个脚本,当从终端编译时,它会传递类似"php compile.php arg1 arg2 arg3 arg4"的参数时,终端上开始显示输出结果,类似于 1)文件创建 2) 文件包含。等。

现在我正在尝试从另一个 php 文件中使用 system(php compile.php arg1 arg2 arg3 arg4),但它不会执行 php 文件或不会显示输出。

例如,我什至尝试创建hello.php------并尝试使用系统(PHP hello.php);但它没有在浏览器上输出任何内容。

任何人都可以帮助我,我是 php 的新手。谢谢。

确保对系统调用中的错误做出反应。您的实际代码也可能有所帮助。以下示例在我的盒子上没有问题。

<?php
$file = fopen('/tmp/written.php', 'w');
fwrite($file, '<?php echo "Hello from written.php'n"; ?>');
fclose($file);
echo "calling written.php'n";
if (!system('php /tmp/written.php'))
    die("something wrong'n");
else
    exit("all good'n");
?>