Welcome Guest, Not a member yet? Register   Sign In
view and terminate
#1

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() ?
Reply
#2

(This post was last modified: 07-25-2018, 08:26 PM by HTLove.)

(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
Reply
#3

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB