I have a class like:
class bla_bla extends WP_Widget {
function boo(){
return 'something';
}
...
}
(it's a WordPress widget)
How can I access the boo()
function from outside the class?
I want to assign the value returned by that function to a variable, like $var = boo();
You can either access it directly or by instantiating the class:
or
First you need an instance of the class. Then you call the method (if it's public). You should read some OOP tutorials as this is really basic stuff. See Object Oriented PHP for Beginners.
You must have an instance of that class to call it, for example:
Otherwise, you can add the "static" keyword to the boo() function, and you could call it like
$var = WP_Widget::boo();
but this changes the semantics and could break code.