PHP attempts to run require_once even though it shouldn't
<p>I am having the strangest time with the following PHP code. The require_once runs in the else statement even though the if statement is true. What is also strange is that $controller in the else statement recieves the value of "application." There is no other code related to the following other than $total's value.</p>

<pre><code>    $total = $uri-&gt;total();

    if($total == 0) {

        //Home Page Controller
        $controller = 'index';
        $method = false;

    } else {

        $controller = $uri-&gt;segment(1); //value is "account"

        if($uri-&gt;segment(2) !== false) {
            $method = $uri-&gt;segment(2); //value is "login"
        } else {
            $method = false;
        }
    }

    require_once(APPPATH.'controllers/'.$controller.EXT);

    $$controller = new $controller;

    if($method != false) {
        $$controller-&gt;$method();
    } else {
        $$controller-&gt;index();
    }
</code></pre>

<p>Edit: I fixed the double-code so that the same code is not called twice in either the if or the else. When I run this, the code works, but I get an error on the line where the require_once is: cannot find application.php</p>

<p>This is strange because require_once is already loading the correct class, but I am getting an error that it cannot find the right file. What would cause it to load twice? I've checked to make sure the file this PHP is in doesn't load twice.</p>

<p>This is all the code I am working with except the URI class found here: <a href="https://github.com/chrisabrams/PHP-URI-Class" rel="nofollow">https://github.com/chrisabrams/PHP-URI-Class</a></p>

<p>I am not sure where application.php comes from.</p>
