title: PHP: How can I get protected values of an object?
body: <p>My Call gets back: print_r($response)</p>
  
  <pre><code>GetItemResponseType Object
  (
      [Item:protected] =&gt; ItemType Object
          (
              [ApplicationData:protected] =&gt; 651034.9.3011
              [BuyerProtection:protected] =&gt; ItemEligible
              [BuyItNowPrice:protected] =&gt; AmountType Object
                  (
                      [attributeValues] =&gt; Array
                          (
                              [currencyID] =&gt; EUR
                          )
  
                      [value:protected] =&gt; 0.0
                  )
  
              [Country:protected] =&gt; DE
  
          )
  
  )
  </code></pre>
  
  <p>I read this (<a href="https://stackoverflow.com/questions/20334355/how-to-get-protected-property-of-object-in-php">How to get protected property of object in PHP</a>), but I can't reproduce the solution.</p>
  
  <p>How can I get the value of Country with i.e. this:</p>
  
  <pre><code>   function accessProtected($obj, $prop) {
        $reflection = new ReflectionClass($obj);
        $property = $reflection-&gt;getProperty($prop);
        $property-&gt;setAccessible(true);
        return $property-&gt;getValue($obj);
      }
  </code></pre>
  
  <p>I get nothing, if I call: </p>
  
  <pre><code>echo accessProtected($response, 'Country');
  </code></pre>
  
  <p>Regards, Matthias</p>