How can PHP scripts be modified to accurately test and display file paths, file existence, and file readability to diagnose file access issues?

To accurately test and display file paths, file existence, and file readability in PHP, you can use functions like `realpath()`, `file_exists()`, and `is_readable()`. By using these functions, you can diagnose file access issues and ensure that the paths are correct, the files exist, and are readable.

$file_path = '/path/to/file.txt';

// Check if the file path is valid
$real_path = realpath($file_path);
if ($real_path) {
    echo "Valid file path: $real_path <br>";

    // Check if the file exists
    if (file_exists($real_path)) {
        echo "File exists <br>";

        // Check if the file is readable
        if (is_readable($real_path)) {
            echo "File is readable";
        } else {
            echo "File is not readable";
        }
    } else {
        echo "File does not exist";
    }
} else {
    echo "Invalid file path";
}