Welcome Guest, Not a member yet? Register   Sign In
Controllers using private variables
#1

[eluser]Unknown[/eluser]
Hello am a codeigniter newbie and am in love with this frame work. I have hit a snag in controllers where by i want to use a private variable in two controllers like this

Code:
class data extends CI_Controller{
private $somedata;


public function index(){
$this->somedata="Got Data here";

}

public function showData(){
echo $this->somedata;
}

}

In the above code when i run the showData() controller it is always empty (My gues is that the class is instantiated in each page am i right? e.g /home/ and /home/showdata will result in two different classes)

My question is how would i set variables in one controller to accessed in another controller?


Messages In This Thread
Controllers using private variables - by El Forum - 08-24-2011, 01:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB