CodeIgniter Forums
Break execution of function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Break execution of function (/showthread.php?tid=68267)



Break execution of function - krystian2160 - 06-17-2017

How to break only execution of particular function?

Assume:

PHP Code:
public function show_main()
{
$this->load->view('main');
$this->f();
$this->load->view('footer');
}

private function 
f()
{
echo 
5;
exit;
echo 
10;


But this example will exit everything. And I have to put $this->output->_display() function above $this->f(); because views won't be shown.

All I want, to just function f() echo 5 and stop this function at this point. Don't echo 10. Don't exit whole output of show_main() and everything.

Just this one function, so I won't need in show_main() to add output, and views main+footer will go to browser

I hope you understand me allthough my english isn't well.
Just to break, stop, exit function, not everything...


RE: Break execution of function - Paradinight - 06-17-2017

(06-17-2017, 05:14 AM)krystian2160 Wrote: How to break only execution of particular function?

Assume:

PHP Code:
public function show_main()
{
$this->load->view('main');
$this->f();
$this->load->view('footer');
}

private function 
f()
{
echo 
5;
exit;
echo 
10;


But this example will exit everything. And I have to put $this->output->_display() function above $this->f(); because views won't be shown.

All I want, to just function f() echo 5 and stop this function at this point. Don't echo 10. Don't exit whole output of show_main() and everything.

Just this one function, so I won't need in show_main() to add output, and views main+footer will go to browser

I hope you understand me allthough my english isn't well.
Just to break, stop, exit function, not everything...

exit stop the application. i do not understand what you need, but you can use return to stop.


RE: Break execution of function - ivantcholakov - 06-17-2017

return;


RE: Break execution of function - krystian2160 - 06-17-2017

Thank you guys Smile.