Is include()/require() with "side effects" a bad practice?
<p>Is doing something like</p>

<pre><code>_________________________
//index.php
...
require("header.php");
...
_________________________

_________________________
//header.php
printHeader()

function printHeader(){
    echo 'something';
    ...
}
_________________________
</code></pre>

<p>considered a bad practice to avoid?</p>

<p>I personally believe that the execution of a <code>require()</code> (or <code>require_once()</code> or <code>include()</code>, that's not the point) call should only add a "link" to other functions/objects and never execute anything on its own. In other words in my opinion a require should behave in a very similar way to the import/using of other oo languages.</p>

<p>The example that I've written above is pretty trivial but obviously I'm writing also against every kind of "side effects". The define function or some tricks with sessions are other abuses that I have found often in some included files.</p>
