How to prevent executing code after setRedirect?
I've place setRedirect in co开发者_JAVA百科ntroller, it does redirect to different controller but still executing rest of the code in first controller.
Usually "redirect" will return "exit()", but "setRedirect" return "void()".
$application = JFactory::getApplication();
$application->enqueueMessage(JText::_('MSG'), 'Warning');
$application->redirect('index.php?option=com_rooms&task=schedule&view=schedule');
like @biswarupadhikari's example, but more J! like with close() method:
$app = JFactory::getApplication();
$app->redirect('index.php?option=com_component');
$app->close();
Use php die() function after setRedirect, it's equivalent to exit()
Use like this way
$mainframe=JFactory::getApplication();
$mainframe->redirect("index.php?option=com_test&task=othertask","Redirected to other task");
exit(0);
精彩评论