在PHP中使用shell_exec调用gcc [英] Calling gcc with shell_exec in php

查看:95
本文介绍了在PHP中使用shell_exec调用gcc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php
$output=shell_exec('gcc prog.c');
echo "$output";
?>

我正在尝试使用php执行ac程序,并使用shell_exec调用gcc来执行该程序,但是它没有给出任何输出,但是没有显示错误。可以请别人纠正错误
,谢谢。

I'm trying execute a c program using php and have used shell_exec to call gcc to execute the program but it is giving no output but there is no error being showed . Can please someone correct the mistake Thank you in advance.

推荐答案

gcc用于编译c文件。它不会运行 .c文件。从命令行尝试。在运行gcc prog.c后,您会发现有一个名为 a.out的文件。 a.out是成功编译prog.c生成的可执行文件。

gcc is used to compile the c file. It doesn't 'run' the .c file. Try it from your command line. You will notice after running gcc prog.c you have a file named 'a.out'. a.out is the executable that is created from the successful compile of prog.c

这篇关于在PHP中使用shell_exec调用gcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆