Jump to content

Code after this line not being parsed?


cgm225

Recommended Posts

I have the following line of code...

 

FrontController::createInstance()->dispatch();

 

However, none of the code after it seems to get rendered/parsed.  So, for example, the following would echo nothing...

 

FrontController::createInstance()->dispatch();
echo "Testing";

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I have included my FrontController class here in case it is the source of the problem:

 

<?php

require_once PAGE_DIR . "/ActionController.php5";

class FrontController {

    //Checking if the PAGE_DIR variable is defined
    public static function createInstance() {
        if (!defined("PAGE_DIR")) {
            exit("Critical error: Cannot proceed without PAGE_DIR.");
        }
        
        
        $instance = new self();
        return $instance;
    }

    public function dispatch() {

        //The next two lines are ternary operators, a sort of short-hand for if-else
        $page = !empty($_GET["page"]) ? $_GET["page"] : "home";
        $action = !empty($_GET["action"]) ? $_GET["action"] : "index";

        //example GuestbookActions
        $class = ucfirst($page) . "Actions";

        //e.g. guestbook/GuestbookActions.php5
        $file = PAGE_DIR . "/" . $page . "/" . $class . ".php5";
        if (!is_file($file)) {
            exit("Page not found");
        }

        //Requiring the Actions file
        require_once $file;

        //Creating a new object
        $controller = new $class();
        //Using the setName variable from the ActionController class in ActionController.php5
        $controller->setName($page);
        //Checks if the method exists, then runs the displayView action
        $controller->dispatchAction($action);
    }
}   

?>



 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/98696-code-after-this-line-not-being-parsed/
Share on other sites

You are probably getting a fatal runtime error or your code is otherwise exiting without displaying any helpful message.

 

Add the following two lines after your first opening <?php tag to get php to help you -

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.