How can include/require statements impact the value of __FILE__ constant in PHP scripts?

When using include/require statements in PHP scripts, the value of the __FILE__ constant may change depending on where the include/require statement is located. To ensure that the value of __FILE__ remains consistent, you can use the magic constant __DIR__ along with the basename() function to get the correct file path.

// Use __DIR__ and basename() to get the correct file path
$filePath = __DIR__ . '/' . basename(__FILE__);

// Now $filePath will always contain the correct file path
echo $filePath;