title: PHP declare encoding
body: <p>On the <a href="https://php.net/manual/en/control-structures.declare.php" rel="nofollow"><code>declare()</code> page of the PHP manual</a>:</p>
  
  <blockquote>
    <h2>Encoding</h2>
    
    <p>A script's encoding can be specified per-script using the encoding
    directive.</p>
    
    <h3>Example #3 Declaring an encoding for the script.</h3>
  
  <pre><code>&lt;?php
  declare(encoding='ISO-8859-1');
  // code here
  ?&gt;
  </code></pre>
  </blockquote>
  
  <ol>
  <li><p>What does this do exactly? How is the behaviour of the script affected by this directive?</p></li>
  <li><p>How does this differ from setting the directives <a href="https://php.net/manual/en/mbstring.configuration.php#ini.mbstring.internal-encoding" rel="nofollow"><code>mbstring.internal_encoding</code></a> (before PHP 5.6) and <a href="https://php.net/manual/en/ini.core.php#ini.default-charset" rel="nofollow"><code>default_charset</code></a> (as of PHP 5.6) or using the <a href="https://php.net/manual/en/function.mb-internal-encoding.php" rel="nofollow"><code>mb_internal_encoding()</code></a> function?</p></li>
  </ol>
  
  <p>(I use both PHP 5.3 and 5.5. Currently my files are saved in UTF-8 and I send the header <code>Content-Type: text/html; charset=utf-8</code> when serving HTML files.)</p>