Welcome Guest, Not a member yet? Register   Sign In
functions within controllers
#1

[eluser]jbuda[/eluser]
i have a function within a controller called 'updateStatus()'

using the syntax : updateStatus()

im trying to call this function from another function within the controller, but it keep erroring sating that updateStatus() is not defined.

i check spelling and case, and it is exactly the sam.

Am i supposed to use something like this to call the function within the controller $this->updateStatus()???
#2

[eluser]sl3dg3hamm3r[/eluser]
[quote author="jbuda" date="1256072249"]Am i supposed to use something like this to call the function within the controller $this->updateStatus()???[/quote]

yes.
#3

[eluser]jbuda[/eluser]
i tried that... but the following error in Apache
PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR
#4

[eluser]khagendra[/eluser]
This can be done by two ways.

1. By using the redirect() function of the url helper. for this the helper url need to be load in the controller.

2. $this->functionName();

Here is an example that demonstrate both the ways

Code:
class Example extends Controller {
    
    function Example()
    {
        parent::Controller();
        
        $this->load->helper('url');
    }
    
    function index()
    {
        $this->show();
    }
    
    function show1()
    {
        echo "two";
    }
    
    function show()
    {
      redirect('example/show1');
    }
}

Try this, it will work.

Quote:Note: the url helper only need to load if u wnat to use redirect('controller/function')
#5

[eluser]n0xie[/eluser]
[quote author="jbuda" date="1256072769"]i tried that... but the following error in Apache
PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR[/quote]
add an ';'




Theme © iAndrew 2016 - Forum software by © MyBB