What are the potential pitfalls of using relative paths in include files in PHP?

Using relative paths in include files in PHP can lead to errors if the current working directory changes or if the file structure is reorganized. To avoid these pitfalls, it is recommended to use absolute paths instead. This ensures that the include files are always referenced correctly regardless of the current working directory.

// Incorrect usage of relative path
include 'includes/header.php';

// Correct usage of absolute path
include __DIR__ . '/includes/header.php';