Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
variable problem
  • i have a class like
    class Controller_Test extends Controller_Template
    {
        private $data = "empty";
        public function action_test1(){
            $this->data = "something";
            echo $this->data;
        }
        
        public function action_test2(){
            echo $this->data;
        }
    }
    

    When calling test1 it prints something. but calling test 2 after test1 prints out empty. is the $data reset everytime i call a function?? how do i fix it?
  • The second time, when you load test2, the function test1 won't be executed so the data won't be set. I think you need to use sessions.
  • The data isn't reset every time you call a function, but it won't persist between HTTP requests (which is why Peter suggested Sessions, those allow for persistance). This is incredibly PHP101 though and has nothing to do with Fuel.
  • abhay rawal wrote on Monday 13th of February 2012:
    Jelmer Schreuder wrote on Sunday 12th of February 2012:
    The data isn't reset every time you call a function, but it won't persist between HTTP requests (which is why Peter suggested Sessions, those allow for persistance). This is incredibly PHP101 though and has nothing to do with Fuel.

    I did knew it had nothing to do with fuel. i just wanted to know if there was some other way rather than sessions. Sorry i did not mention that. Anyways, thanks for your replies.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion