What are best practices for handling file paths when using the "require_once" function in PHP?

When using the "require_once" function in PHP, it is important to handle file paths correctly to ensure that the files are included properly. One best practice is to use the magic constant "__DIR__" to get the absolute path of the current file and then construct the path to the required file relative to that. This ensures that the file paths are consistent and work across different environments.

<?php
require_once __DIR__ . '/path/to/required/file.php';
?>