How can the output of a command executed using "exec" in PHP be captured and stored in a variable?

When using the "exec" function in PHP to execute a command, you can capture the output by redirecting it to a variable using the output parameter. This allows you to store the result of the command in a variable for further processing or display. By specifying the output parameter, you can easily access the output of the executed command within your PHP script.

$output = '';
exec('your_command_here', $output);
var_dump($output);