![]() |
Exiting the application - simple issue - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Exiting the application - simple issue (/showthread.php?tid=9300) Pages:
1
2
|
Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]EEssam[/eluser] Hello, I need to check for something in my Controller constructor and if the condition is met, I need display a view and exit the application. if (1 == 1) { $this->load->view('closed', $this->data); exit; } The code above is showing a blank page. Please help. Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]libnac[/eluser] I think you should only load a view and quit the exit function because CI will never renders the final output. Also, you can use $this->output->set_output($any_text_or_html) in order to display any message. Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]EEssam[/eluser] Hi, If I remove the exit function the rest of the code will be executed ![]() I just need to show the view called 'closed' Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]libnac[/eluser] Enclosed rest of code with an else sentence can be a solution Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]EEssam[/eluser] I thought about that but it's not logical at all. What if the visitor supply a method name that do exist? It will be executed unless I put my code in every method I have!!! Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]ontguy[/eluser] You could try using "return;" instead of "exit;". Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]arume[/eluser] Maybe putting this in your controller: Code: function _remap($method) Of course, you must change 1 == 1 for your logic. Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]Rick Jolly[/eluser] It won't work because of CI's output buffering. Try this: Code: ob_start(); Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]EEssam[/eluser] Thanks guys, Rick's code worked fine. Exiting the application - simple issue - El Forum - 06-20-2008 [eluser]arume[/eluser] [quote author="Rick Jolly" date="1214005320"]It won't work because of CI's output buffering.[/quote] I am using it and, as far as I know, it works. Can you say me where is the error? Thanks. |