title: PHP: Use (or not) 'utf8_encode' in combination with setting BOM to \xEF\xBB\xBF
body: <p>When using the following code:</p>
  
  <pre><code>$myString = 'some contents';    
  $fh=fopen('newfile.txt',"w");
  fwrite($fh, "\xEF\xBB\xBF" . $myString);
  </code></pre>
  
  <p>Is there any point of using PHP functions to first encode the text ($myString in the example) e.g. like running <code>utf8_encode($myString);</code> or similar <code>iconv()</code> commands?</p>
  
  <p>Assuming that the BOM <code>\xEF\xBB\xBF</code> is first inputted into the file and that UTF8 represents practically all characters in the world I don't see any potential failure scenarion of creating a file this way. In other words I don't see any case where any major text editor wouldn't be able to interpret the newly created file corectly, displaying all characters as intended. This even if <code>$myString</code> would be a PHP <code>$_POST</code> variable from a HTML form. Am I right?</p>