How can the __DIR__ constant be used to improve file path security in PHP scripts?

Using the __DIR__ constant in PHP scripts can improve file path security by providing an absolute path to the directory of the current script. This ensures that file operations are performed relative to the current script's location, reducing the risk of path traversal attacks.

// Using __DIR__ to include a file securely
include __DIR__ . '/path/to/file.php';