skip to Main Content

My Call gets back: print_r($response)

GetItemResponseType Object
(
    [Item:protected] => ItemType Object
        (
            [ApplicationData:protected] => 651034.9.3011
            [BuyerProtection:protected] => ItemEligible
            [BuyItNowPrice:protected] => AmountType Object
                (
                    [attributeValues] => Array
                        (
                            [currencyID] => EUR
                        )

                    [value:protected] => 0.0
                )

            [Country:protected] => DE

        )

)

I read this (How to get protected property of object in PHP), but I can’t reproduce the solution.

How can I get the value of Country with i.e. this:

   function accessProtected($obj, $prop) {
      $reflection = new ReflectionClass($obj);
      $property = $reflection->getProperty($prop);
      $property->setAccessible(true);
      return $property->getValue($obj);
    }

I get nothing, if I call:

echo accessProtected($response, 'Country');

Regards, Matthias

2

Answers


  1. Chosen as BEST ANSWER

    the answer to my question is:

    echo $response->Item->Country;
    

    Thank You.


  2. You should create getter and setter functions which are public or static in your class.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search