What are some best practices for managing PHP files that need to be included without displaying output?

When including PHP files that do not need to display output, it is best practice to wrap the code in a function to prevent any unintended output. This ensures that the included file only runs the necessary logic without displaying anything on the page.

// Create a function to encapsulate the code in the included file
function include_file_without_output() {
    // Include the PHP file with the necessary logic
    include 'file_to_include.php';
}

// Call the function to execute the code in the included file
include_file_without_output();