I have a HelloWorld.java located on my server, and I’d like to compile this program using “javac” within php.
So, I have the following code
<?php
exec("javac HelloWorld.java", $array);
print_r($array);
?>
And the output is
Array ( )
What am I doing wrong? javac.exe is located in the same spot this php file is.
Any help would be much appreciated. Thanks!
This should surely help you
http://www.ibm.com/developerworks/opensource/library/os-php-commandline/index.html
The output parameter gets only standard output, if you need error output too, don’t forget to redirect it.
If the output parameter is still empty after an execution and if it shouldn’t, you must be in this case.
http://us.php.net/manual/en/function.exec.php
Or
use passthrough. It looks similar to execute.
Read the links provided.
Something like this:
I don’t know about drawbacks that this method might have. Maybe and increased overhead? Anyway I was happy to circumvent the problem with it.
http://us.php.net/manual/en/function.passthru.php