What are the best practices for displaying shell-exec output in HTML without disrupting the user interface?

When displaying shell-exec output in HTML, it's important to sanitize the output to prevent any potential security vulnerabilities. One way to do this is by using the htmlspecialchars function in PHP to escape any special characters that could disrupt the user interface. By doing this, you can safely display the shell-exec output in HTML without causing any issues.

// Get the shell-exec output
$output = shell_exec('your_shell_command_here');

// Sanitize the output using htmlspecialchars
$sanitized_output = htmlspecialchars($output, ENT_QUOTES);

// Display the sanitized output in HTML
echo "<pre>{$sanitized_output}</pre>";