How do I access the value of stdClass with colon \":protected\"?
For example, I had this $obj with these result :
object(Google_Service_Plus_PeopleFeed)
Please note that there is probably a reason that these properties are protected, so you should think twice before trying to access them.
If you need to access protected variables, you could use Reflection, but there might be an easier solution. By binding a closure to the object, you should be able to access the protected variables from the closure:
class X {
protected $a = 10;
public $b = 20;
}
$closure = function() {
return get_object_vars($this);
};
$result = Closure::bind($closure, new X(), 'X');
var_dump($result());