How can the use of predefined constants like __DIR__ improve PHP code readability and security?

Using predefined constants like __DIR__ can improve PHP code readability and security by providing a clear and consistent way to reference file paths. This helps prevent errors and makes the code easier to understand for other developers. Additionally, using predefined constants can help prevent directory traversal attacks by ensuring that file paths are always resolved relative to the current file's directory.

// Without using predefined constant
include '/var/www/html/includes/config.php';

// Using predefined constant __DIR__
include __DIR__ . '/includes/config.php';