How can you differentiate between output from the main script and included files in PHP?

To differentiate between output from the main script and included files in PHP, you can use the `__FILE__` magic constant to check if the output is coming from the main script or an included file. You can then include this check in your code to display a message or perform a specific action based on where the output is coming from.

<?php
if (__FILE__ === $_SERVER['SCRIPT_FILENAME']) {
    echo "Output from the main script.";
} else {
    echo "Output from an included file.";
}
?>