I have a file named gcc.exe and I have a php page... I want to use:
gcc test.c
And, if there's some compilation error, I want to show it on the php page... But I can't. What happens is: If the file is correct, it generates the .exe file, but if it's wrong, nothing happens. What I want here, again, is to show all errors.
Anyone has an idea?
Edit[1]: Some code:
<?php
exec("gcc teste.c",$results);
print_r($results)
?>
Output:
*Nothing*
Edit[2]: I tryed put gcc output on a text file: This way (on prompt):
gcc test.c > teste.txt
Teorically, everythings on the screen go to text file. But this was unsucessfuly!
Edit[3]: quantumSoup:
I tryed it, and...
array(0) { } int(1)
Nothing... Anything more?
gcc is likely to generate error output on stderr
, which it would appear exec
doesn't capture in the $results array. Solutions to this are likely to be kinda platform-specific. If you're working in a unix-like environment, it would be possible to do something like gcc foo.c 2>&1
to redirect stderr to stdout. I've no clue how one might achieve that on Windows, or if analogous concepts even exist. Perhaps someone else can elaborate if your question is platform-specific.
This is supported by the fact that piping to a file didn't work either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With