Welcome Guest, Not a member yet? Register   Sign In
How use controller property after requests
#1

Hello,
How we can endure a state of a controller property after a request in CodeIgniter version 4. For example, imagine that $a is a complex object:


/ the controller complains that the variable $a must not be accessed before initialization
Code:
class Example extends BaseController
{
    private int $a;

   public function index()
   {
       $this->a = 7;
      return view('welcome');
   }

   public function checkVariable()
   {
      // the code igniter complains that $a must not be accessed before initialization, but it was when index() was called
      var_dump($a);
   }
}

Some other languages we have something to sustain the state of those variable. What we have on CodeIgniter? Are there some helper to import to do that for us?

Thanks in advance.
Reply


Messages In This Thread
How use controller property after requests - by danielsonsilva - 05-04-2020, 06:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB