How can the output of a system command be captured and handled in PHP?

To capture the output of a system command in PHP, you can use the `exec()` function. This function allows you to execute a command and capture the output into a variable for further processing or handling. By using `exec()`, you can easily interact with the command line from your PHP script and work with the results as needed.

// Execute a system command and capture the output
$output = exec('ls -l');

// Handle the output as needed
echo $output;