Accessing a protected member variable outside a class

Viewed 46720

I'm querying for the ID of a field by accessing a class function which someone has already put in place. The result is a object returned with protected member variables. I'm struggling to see how I can access the member variable values outside the class.

8 Answers

with closure acces php protected variable for example

class ForExample
{
    protected $var=122;
}



$call=function(){

    echo $this->var;
};

$call->call(new ForExample());
Related