What are some best practices for handling file inclusion in PHP to avoid open_basedir errors?

When handling file inclusion in PHP to avoid open_basedir errors, it is important to ensure that the included files are within the allowed directory paths specified in the open_basedir directive. One way to do this is to use absolute paths when including files, as relative paths can lead to errors. Additionally, it is recommended to sanitize user input and validate file paths before including them to prevent any security vulnerabilities.

<?php
$included_file = '/path/to/allowed/file.php';

if (is_readable($included_file)) {
    include $included_file;
} else {
    // handle error or log a message
}
?>