If you do a redirect in CakePHP 1.1 you often have to add an exit() after the redirect statement to stop the script execution:
$this->redirect('controller/action');
exit();
Thanks to a small enhancement in CakePHP 1.2 in the form of an additional parameter for the redirect() function you can now do:
$this->redirect('controller/action', null, true);
It’s the same functionality as in the previous code snippet, but with the advantage that your code becomes testable (you cannot test a function which contains an exit(), as the exit() also stops the execution of the test).
2007年7月28日 星期六
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言