Let's say I have the following:
class Submit extends \RightNow\Models\Base
{
function __construct()
{
parent::__construct();
}
function inner () {
return $i++;
}
function outer(){
$i = 0;
$this->inner();
echo $i;
}
}
$submit = new Submit();
$submit->outer();
How is it possible for inner() to access the variable $i that was declared in outer()? I've tried using global but this didn't work.
I understand in my very basic example, I could pass the variable in as a parameter but this just serves as an example for my question
I am using CodeIgniter