Compile file with system function
I want to compile a .c file using PHP’s system
function and display the th开发者_如何学Ce error (if any) to another text field, else display nothing. How can I do that?
You could launch a compilation command with system
function:
$output = system("gcc -Wall -c yourtmpfile.c");
outtmpfile.c
is a temporary file you need to create.
In $output
you will have the output of the compilation command.
http://www.php.net/manual/en/function.system.php
"If the return_var argument is present, then the return status of the executed command will be written to this variable."
Then write the content of the variable to your textfield...
Take a look at PHP's system()
function.
echo system('gcc file.c');
精彩评论