title: PHP Generate RSS XML - Encoding Error
body: <p>So I have a small PHP script that generates an xml feel for the rss feed of my blog. However, it throws up this error:</p>
  <blockquote>
  <p>This page contains the following errors:</p>
  <p>error on line 23 at column 14: Encoding error<br />
  Below is a rendering of the page up to the first error.</p>
  </blockquote>
  <p>(seen here: <a href="http://aviatex14.co.uk/rss.xml" rel="nofollow noreferrer">http://aviatex14.co.uk/rss.xml</a>)</p>
  <p>Here's the code that generates it:</p>
  <pre><code>while ($line = mysql_fetch_array($result)) {
    $return[] = $line;
    var_dump(date(&quot;Y-m-d H:i:s&quot;, $line['timestamp']));
  }
  
  $now = date(&quot;D, d M Y H:i:s T&quot;);
  
  $output = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-16\&quot; ?&gt;
               &lt;rss version=\&quot;2.0\&quot;&gt;
                  &lt;channel&gt;
                    &lt;title&gt;&lt;/title&gt;
                    &lt;link&gt;&lt;/link&gt;
                    &lt;description&gt;&lt;/description&gt;
                    &lt;pubDate&gt;&lt;/pubDate&gt;
                    &lt;language&gt;en-us&lt;/language&gt;
                      
                    &lt;lastBuildDate&gt;$now&lt;/lastBuildDate&gt;
            &quot;;
              
  foreach ($return as $line) {
    $output .= &quot;&lt;item&gt;&lt;title&gt;&quot;.htmlentities($line['title']).&quot;&lt;/title&gt;
                  &lt;link&gt;http://blog.aviatex14.co.uk/permalink.php?uid=&quot;.htmlentities($line['uid']).&quot;&lt;/link&gt;     
                  &lt;description&gt;&quot;.htmlentities(strip_tags($line['entry'])).&quot;&lt;/description&gt;
                  &lt;pubDate&gt;&quot;.$date = date(&quot;Y-m-d H:i:s T&quot;, $line['timestamp']).&quot;&lt;/pubDate&gt; 
                &lt;/item&gt;&quot;;
  }
  $output .= &quot;&lt;/channel&gt;&lt;/rss&gt;&quot;;
  print &quot;Content-Type: application/rss+xml&quot;;
  echo $output;
  
  $f = fopen(&quot;rss.xml&quot;, &quot;w&quot;); 
  fwrite($f, $output); 
  fclose($f); 
  </code></pre>
  <p>Any help would be appreciated! :D</p>