How can the PHP script be modified to prevent the "File exists" warning message from appearing?

The issue of the "File exists" warning message appearing can be solved by checking if the file exists before attempting to create it. This can be done using the `file_exists()` function in PHP to avoid the warning message. By checking if the file exists before creating it, we can prevent the warning message from being displayed.

$filename = "example.txt";

if (!file_exists($filename)) {
    $file = fopen($filename, "w");
    fwrite($file, "Hello, World!");
    fclose($file);
} else {
    echo "File already exists.";
}