title: How expensive is the include/import directive?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4890825/cost-of-include-in-php">cost of “include” in PHP?</a>  </p>
  </blockquote>
  
  
  
  <p>This question is specifically about <a href="http://php.net/" rel="nofollow noreferrer">PHP</a>, but I'm pretty sure that he answer, in nature, is similar for most modern programming languages that support classes (at least interpreted ones).</p>
  
  <p>When you <a href="http://php.net/manual/en/function.include.php" rel="nofollow noreferrer">include</a> or use a class (using <a href="http://php.net/manual/en/language.namespaces.php" rel="nofollow noreferrer">namespaces</a> for PHP >= 5.3.0), how much processing resources are spent?</p>
  
  <p>For example, imagine there's a big PHP script file <code>Database.php</code> that has over a couple thousand lines of code, and you import it in another script:</p>
  
  <pre><code># PHP &gt;= 5.3.0
  use Service\Database;
  </code></pre>
  
  <p>or</p>
  
  <pre><code># in previous versions
  include Service/Database.php;
  </code></pre>
  
  <p>I'm unsure of what happens behind the curtain in this case. Does it load <em>all</em> the class into working memory or just the functions you actually get to use? If you import it but don't use any of it, does it still waste resources?</p>