CodeIgniter Forums
view and terminate - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: view and terminate (/showthread.php?tid=71273)



view and terminate - anthos1984 - 07-25-2018

On CI3 if I want to view pages :

PHP Code:
$this->load->view('paket/list.min.html'); 


That automatically exit. So I do check like this

PHP Code:
if( ! $check ){
 
    $this->load->view('page_not_found.min.html');
}
// process something
$this->load->view('page_success'); 
And when check fails, then page_success wont executed.
How to do that in CI4? Did it safe to just call exit() ?


RE: view and terminate - HTLove - 07-25-2018

(07-25-2018, 04:30 PM)anthos1984 Wrote: On CI3 if I want to view pages :

PHP Code:
$this->load->view('paket/list.min.html'); 


That automatically exit. So I do check like this

PHP Code:
if( ! $check ){
 
    $this->load->view('page_not_found.min.html');
}
// process something
$this->load->view('page_success'); 
And when check fails, then page_success wont executed.
How to do that in CI4? Did it safe to just call exit() ?


You can use:
PHP Code:
if( ! $check ){
 
    return view('page_not_found.min.html');
}
// process something
return view('page_success'); 

Thanks


RE: view and terminate - John_Betong - 07-25-2018

Check the manual for the array of parameters that can be passed so that the view function returns a string.. which may later be tested or displayed.

Adding an else clause to the if statement may also help.