Is it a good/neutral/bad practice to use $this as a file-level variable in PHP (e.g. functions spanning files)?
<p>It's kinda hard to explain what I mean, I don't know how to name this pattern, so I'll explain with an example:</p>

<h3>First.php:</h3>

<pre><code>&lt;?php
    class MyClass
    {
        public $Meaning = 42;

        public function MyFun
        {
            include("Second.php");
        }
    }
?&gt;
</code></pre>

<h3>Second.php:</h3>

<pre><code>&lt;div&gt;&lt;?= $this-&gt;Meaning ?&gt;&lt;/div&gt;
</code></pre>

<p>In the <strong>Second.php</strong> we rely on being included from a method in <code>MyClass</code>, and use the <code>$this</code> variable. Somehow this feels... unnatural to me. Maybe it's because of my C# background, but I strongly feel that <strong>functions don't span files</strong>. Classes might, but not functions (OTOH spanning classes is exactly what PHP does <em>not</em> allow).</p>

<p>So... am I being unreasonable in this, or is this really considered a bad practice? Or perhaps in view-logic (think MVC) this is even the standard approach?</p>
