PHP Exec debugging

/ Published in: PHP
Save to your folder(s)

easy way of catching and displaying errors and return values from a exec() command back in PHP.

Copy this code and paste it in your HTML
  1. exec("java -jar some command 2>&1 &", $return, $code);
  2. if ($code != 0) {
  3. printf("Fuck! Something went wrong: %s (%s)", join('<br />', $return), $code);
  4. } else {
  5. print("Command successful.");
  6. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.