Function in Controller

#1
[eluser]reidz[/eluser]
i want to ask how to handle request to function which do not show anyting to controller

Code:
class Example extends Controller
{
    function Example()
    {
        parent::Controller();
    }
    
    function index()
    {
        $this->load->view('some_view');
    }
    
    function do_nothing()
    {
        
    }
    
}

with this Controller, when i type this localhost/index.php/example/do_nothing on my address bar, the result is just blank page, because that function do_nothing do not called any view

so all im asking is how we handle this kind situation ? cause i dont want to display any blak page

#2
[eluser]InsiteFX[/eluser]
Well do_nothing needs to be coded with do_something.

What do you want to do in do_nothing?

InsiteFX

#3
[eluser]reidz[/eluser]
in my case i generate some encrypted password and then i return that password to function in controller
so when i try to call that function, blank page shown
any suggestion ?

#4
[eluser]InsiteFX[/eluser]
Try this in do_nothing.
Code:
redirect('example/index', 'refresh');

InsiteFX

#5
[eluser]vitoco[/eluser]
why not put that function in a helper or library ?? or al least in a private function ?

Saludos

#6
[eluser]Matt S.[/eluser]
Prepend do_nothing() with an underscore, like so:

Code:
function _do_nothing()
{

}

This will make it "private" and prevent it from being called from the URL. You can optionally remap it to a different method using the _remap method.

Code:
function _remap($method)
{
    if($method == 'do_nothing')
    {
          $this->index();
    }
}

#7
[eluser]reidz[/eluser]
stupid me, thanks im totally forgot to make private function
i've already made library for some of my function though
thank you, problem solved


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.