Passing data between two functions in my controller class |
[eluser]See64[/eluser]
I'm a bit of newbie and I'm trying to use CI to get my PHP programming straight. Now I ran into this problem, that I sorta asked before on here: link to thread. (I got an answer to my original problem, not the passing-of-variables question). The question simply is: how do I pass variables from one function to another? I want all my functions to return to the index() one, and I want to able to send a status message, something like this: Code: class Test extends Controller { How do I accomplish this? Many thanks in advance.
[eluser]deand[/eluser]
Hi See64, Code: class Test extends Controller { Does this help?
[eluser]deand[/eluser]
Actually, you will have a problem with index() so I think this will be better: Code: class Test extends Controller {
[eluser]See64[/eluser]
Hi deand, thanks for your answer. This works like a charm, and that's the way I thought it would work. The reason it didn't work for me, was that I also did a redirect after the $this->index();. That way it called index() twice, whereby $this->message would be empty the second time. Oh, how I hate monday mornings
[eluser]John_Betong[/eluser]
Hi See64, Here is the method I would use: Code: <?php Cheers, John_Betong
[eluser]Unknown[/eluser]
Hi There, I have an issue with this - I am writing an API style interface where different external triggers post data to my system and cause different actions to happen. The way data is sent is set, so I can't modify - and varies, so I have to have different circumstances. Basically, I have a bunch of functions like this: Code: $user_info = $this->profile->get_user_by_email($this->input->get('Email')); $this->profile->status is the only thing that is different, the get_user_by_email stuff is repeated in a ton of functions. I'd love it to look something like this Code: $this->get_user_info_function(); Is that possible? Or, because I'm using GET, does it have to be in the same function that the data is posted to? |
Welcome Guest, Not a member yet? Register Sign In |