How can including external files or scripts impact header modification in PHP?

Including external files or scripts in PHP can impact header modification if those files contain header modification functions or code. This can lead to conflicts or unexpected behavior when setting headers in multiple files. To solve this issue, it's important to ensure that header modification is done consistently and centrally in one location, such as a main PHP file, to avoid conflicts and maintain control over the headers being sent.

// main.php

// Set headers before any output is sent
header("Content-Type: text/html; charset=utf-8");
header("X-Frame-Options: DENY");

// Include external files or scripts
include 'header_modification_functions.php';
include 'other_script.php';

// Rest of the PHP code