What are the potential pitfalls of using the * file mode in PHP fopen?

Using the * file mode in PHP fopen can be risky as it allows both reading and writing to a file, which can potentially overwrite existing data. To avoid this pitfall, it's recommended to use the "r+" mode for reading and writing without truncating the file.

$file = fopen("example.txt", "r+");
if ($file) {
    // Read or write to the file here
    fclose($file);
} else {
    echo "Unable to open file.";
}