开发者

PHP attempts to run require_once even though it shouldn't [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 8 years ago.

Improve this question

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 "applica开发者_开发技巧tion." There is no other code related to the following other than $total's value.

    $total = $uri->total();

    if($total == 0) {

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

    } else {

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

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

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

    $$controller = new $controller;

    if($method != false) {
        $$controller->$method();
    } else {
        $$controller->index();
    }

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

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.

This is all the code I am working with except the URI class found here: https://github.com/chrisabrams/PHP-URI-Class

I am not sure where application.php comes from.


You have the same require_once statement in both the 'if' and 'else' blocks.


This has been resolved: http://codeigniter.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜