How can the __DIR__ magic constant be used to improve file inclusion in PHP scripts?

When including files in PHP scripts, it's important to consider the directory structure to ensure that the correct path is used. The __DIR__ magic constant can be used to get the directory of the current file, making it easier to include files relative to that location. This can help prevent errors and make the script more portable.

// Include a file using __DIR__
include __DIR__ . '/includes/config.php';