redirect - PHP MVC correct redirecting, is die needed? -
what correct way redirect controller in php mvc structure?
lets have controller class:
abstract class controller { public function __construct() { // code here } abstract protected function index(); protected function redirect($location = 'index') { header('location:' . url . $location); die(); // <-not shure if die right here } }
and in class need verify condition , redirect place if false
class logincontroller extends controller { public function __construct() { parent::__construct(); // more code here } public function index() { if ($this->session->verifyuserstatus()) { $this->redirect('admin'); } $this->view->render('login'); } }
should need call die() function @ end of redirector? or ending script fine?
regards
you can end normally, die() isn't necessary.
Comments
Post a Comment