What are the common pitfalls when trying to create a Word document using PHP?

One common pitfall when trying to create a Word document using PHP is not setting the correct content-type header, which can lead to the document not being recognized as a Word file. To solve this, make sure to set the content-type header to 'application/msword' before outputting any content.

<?php
header("Content-Type: application/msword");
// Rest of the code to create the Word document goes here
?>