I have a PHP class like the following
<?php
class Test{
var $conf = array('a' => 1, 'b' => 2, c => 3);
private function do_something(){
// Do something Here
function do_something_else(){
// How to get the variable value for $conf ???? o.O
}
}
}
?>
I want to access $conf inside the function do_something_else(). In the upper level functions I am able to access this as $this->conf, but I guess $this would not be available in the inner function. What would be the best possible way to access the variables inside that function?
I cannot pass the values as this function would be called by a built-in function in WordPress CMS, so passing arguments can not be a choice here.
I believe what you need is anonymous function, here is some solutions.
You can do in PHP 5.3:
Or use
$thisdirectly on anonymous function but only PHP 5.4.