What is the common error in writing HTML links to a text file using PHP fwrite?

The common error in writing HTML links to a text file using PHP fwrite is that the HTML tags are not properly formatted. To solve this issue, you need to make sure that the HTML tags are enclosed within double quotes and properly escaped.

$file = fopen("links.txt", "w");
$link = "<a href='https://www.example.com'>Example Link</a>";
fwrite($file, $link);
fclose($file);