PHP Throws error when calling class method inside function : <pre><code>include "sys.php";

$logger = new logger();
$logger-&gt;write("Hello!");
</code></pre>

<p>This works. However,</p>

<pre><code>include "sys.php";

$logger = new logger();

function test() {
    $logger-&gt;write("Hello!");
}

test();
</code></pre>

<p>This does not. The server crashes, error 500.</p>

<p>Why?</p>
