I have a function that permits access to something I've never seen before a variable function.
normal functionality:
$api = api_client($special_data);
$data = $api('get','something.json'); // notice $api() not a mistake
The problem with this above example is that I am createing the $api variable in each function / method of my controller. I would like to do something like this:
public $api;
public function somepage(){
$special_data = get_special_data_from_this_method();
$this->api = api_client($special_data);
}
public function anotherpage(){
$data = $this->api('get','something.json'); // api is not a function it is a variable function
}
I did find that the following works, although I am not satisfied with it
public function somepage(){
$special_data = get_special_data_from_this_method();
$this->api = api_client($special_data);
$temp = $this->api;
$data = $temp('GET', '/admin/orders.json');
}
Hope this makes sense would love the help!