['pipe', 'w'], // stdout is a pipe that the child will write to 2 => ['pipe', 'w'], // stderr is a pipe that the child will write to ]; // Open the process $process = proc_open($command, $descriptorspec, $pipes); if (is_resource($process)) { // Get the output from stdout and stderr $output = stream_get_contents($pipes[1]); $error = stream_get_contents($pipes[2]); // Close the pipes fclose($pipes[1]); fclose($pipes[2]); // Close the process and get the exit code $return_value = proc_close($process); // Display the output echo "
$output
"; // Check for errors if ($error) { echo "
Error: $error
"; } } ?>