What are the potential consequences of using incorrect file paths in PHP when reading text files?

Using incorrect file paths in PHP when reading text files can lead to errors such as "file not found" or "permission denied." To solve this issue, make sure to provide the correct file path relative to the location of the PHP script, and ensure that the file has the necessary permissions for reading.

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

if (file_exists($file_path) && is_readable($file_path)) {
    $file_contents = file_get_contents($file_path);
    echo $file_contents;
} else {
    echo "Error: Unable to read file.";
}