How can the use of the exec() function in place of system() help resolve header modification errors in PHP scripts?

Using the exec() function instead of system() can help resolve header modification errors in PHP scripts because exec() does not return the output of the command, which can interfere with header modifications. By using exec(), the script can safely modify headers without any interference from command output.

<?php

// Original code using system() function
// system('command');

// Updated code using exec() function
exec('command');

// Rest of the PHP script
?>