What potential issues can arise when using the 'w' mode to open a file in PHP for writing?

When using the 'w' mode to open a file in PHP for writing, one potential issue that can arise is that it will truncate the file to zero length if it already exists. This means that any existing content in the file will be deleted. To avoid this issue, you can use the 'a' mode instead, which will open the file for writing without truncating it.

$file = fopen("example.txt", "a") or die("Unable to open file!"); // Open file in 'a' mode
fwrite($file, "New content to append\n"); // Write new content to file
fclose($file); // Close the file