I tried to call the above compile function from the directory /var/www/. I could get the result by manual execution of gcc command but i could not create an executable file by running the same command from php using shell_exec(), though i could get the result of "shell_exec('./Compile'); ". Kindly let me know the issues.
I have never tried such thing. PHP is compiled in C, to have PHP call the compiler is not the logical way to go. What is the need to use PHP on that, do you want the compilation to occur when something comes from net. And maybe the answer is that ... what exactly you are trying to do ...
I am developing an online testing system through which we can conduct online programming contests.
For the same i want to invoke the C compiler from the php script using the functions like system(), shell_exec(), exec() etc. But the function is not returning the result when i call the C compiler as in the following code:
$a=shell_exec('gcc -o Compile Compile.c'); //Code is not returning anything
$b=shell_exec('./Compile'); // Code is working
1) The process created by PHP will be run as the PHP user. Does this user have the required permissions.
2) If you're getting errors, you would need to access stderr. Try "2>&1" at the end to redirect stderr to stdout.
3) Compiling takes time, you might want to do it asynchronously with the PHP process and have PHP monitor it. You can use proc_open() and stream_select() to listen to changes. This also gives you access directly to the stderr output which would be useful.
can someone plzz tell me code for compiling c/c++ program via php on windows 7 platform.
i m using xampp on my local machine.
i hv no idea abt hw to do dat...plzzzz help me..
.its very urgent...
wht fuction i cn use...??