How can the script be modified to correctly handle file paths and prevent the warning message?

The issue with the current script is that it does not handle file paths correctly, leading to a warning message when trying to read the file. To solve this issue, we can use the `__DIR__` magic constant to get the absolute path to the current script and then concatenate the file path to it. This ensures that the file path is correctly resolved and the warning message is prevented.

<?php

$file_path = __DIR__ . "/data.txt";

if(file_exists($file_path)){
    $data = file_get_contents($file_path);
    echo $data;
} else {
    echo "File not found.";
}