I have controller that has functions and I want to use one variable through them
class TrainerController extends \BaseController {
public function one(){
$variable = "some data";
}
public function two()
{
//How to use $variable here ?!
}
}
I tried to use session but session scope in one function (view) only thanks in advance
Make it a property
class TrainerController extends \BaseController
{
private $variable;
public functionOne(){
$this->variable = "some data";
}
public functionTwo()
{
echo $this->variable; //outputs 'some data' IF this 1st method has already been called
}
}