By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

Passing java output to variable in PHP code.

P: 2

I am trying to pass the output of java executable to a variable. After executing the java using system command in PHP, it produces two ouput files. I just need one of them with the extension *.arff to process further. How can I capture the output in a variable???

Expand|Select|Wrap|Line Numbers
  1. $name = "user.sdf";
  2. $fh = fopen("$name", "r+");
  3. if($fh==false)
  4.     die("unable to create file");
  6. if (file_exists("$name")) {
  7.   echo "$name";
  8. system("/usr/java/jdk1.6.0_16/bin/java -jar -Xmx512M ODDescriptors.jar -f $name -l KI");
Jun 24 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 6,050
See the exec function, and, more specifically, its $output parameter.
Jun 27 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.