编译 C++使用PHP

发布于 2024-12-29 18:30:19 字数 628 浏览 2 评论 0原文

我正在尝试使用 PHP 开发一个在 Linux 上托管的在线法官

我在 test.php 文件中编写了下面的代码

<?php
    exec("sudo chown `rofaelemil` /var/www", $output, $returnVal);
    exec("g++ /var/www/qwerty.cpp -o /var/www/binary", $output, $returnVal);
    echo $output;
    exec("cat /var/www/qwe.txt | /var/www/binary", $output, $returnVal);
    echo $output;
    exec("gcc /var/www/qwerty.c -o /var/www/binary", $output, $returnVal);
    echo $output;
    exec("cat /var/www/qwe.txt | /var/www/binary", $output, $returnVal);
    echo $output;
?>

输出是

ArrayArrayArrayArray

任何人都可以配置问题吗

I'm trying to develop an online judge using PHP to be hosted on linux

I wrote the code below in test.php file

<?php
    exec("sudo chown `rofaelemil` /var/www", $output, $returnVal);
    exec("g++ /var/www/qwerty.cpp -o /var/www/binary", $output, $returnVal);
    echo $output;
    exec("cat /var/www/qwe.txt | /var/www/binary", $output, $returnVal);
    echo $output;
    exec("gcc /var/www/qwerty.c -o /var/www/binary", $output, $returnVal);
    echo $output;
    exec("cat /var/www/qwe.txt | /var/www/binary", $output, $returnVal);
    echo $output;
?>

The output was

ArrayArrayArrayArray

Could anyone configure the problem

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝颜夕 2025-01-05 18:30:19

$output 包含您逐行exec 的程序的输出,您无法回显数组,print_r 它。

下次请查阅 php 的文档,你可以在那里得到这些信息。请参阅 exec

$output contains the output of the program you execed, line by line, you can't echo an array, print_r it.

Next time please consult the documentation of php, you could have gotten this information there. See exec.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文