I tried this but couldn't get it to work:
class Profile extends CI_Controller {
public function index() {
$foo = 'bar';
}
public function form_submit() {
echo $this->index()->foo;
}
}
I know I can make a variable accessible to all the methods in a class by declaring it outside all the methods at class level and declaring it as public. But here I need to declare the variable inside one of the methods.