0

How do you point to the cid and get the value?

$item->?

array(1) {
  [0]=>
  object(__PHP_Incomplete_Class)#4 (4) {
    ["__PHP_Incomplete_Class_Name"]=>
    string(7) "Product"
    ["_param:protected"]=>
    array(40) {
      ["pid"]=>
      string(3) "540"
      ["cid"]=>
      string(2) "22"
      ["sid"]=>
      string(1) "1"
      ["tid"]=>
      string(1) "9"
      ["sales_volume"]=>
      string(1) "0"
      ["preorder_volume"]=>
      string(1) "0"
      ["viewed"]=>
      string(1) "0"
      ["weight"]=>
      string(4) "0.00"
      ["delivery_type"]=>
      string(6) "postal"
      ["cash_price"]=>
      string(4) "0.00"
      ["coupon_price"]=>
      string(4) "0.00"
      ["coupon_require"]=>
      NULL
      ["member_price"]=>
      NULL
      ["discount_code"]=>
      NULL
      ["special_offer"]=>
      string(1) "0"
      ["lan"]=>
      string(13) "eng,tchi,schi"
      ["special_offer_price"]=>
      string(4) "0.00"
      ["special_offer_begin"]=>
      string(19) "2010-09-06 11:25:05"
      ["special_offer_end"]=>
      string(19) "2010-09-06 11:25:05"
      ["bonus_point"]=>
      string(1) "0"
      ["tax"]=>
      string(4) "0.00"
      ["release_date"]=>
      string(19) "2010-09-06 11:25:05"
      ["begin_datetime"]=>
      string(19) "2010-07-13 14:41:26"
      ["end_datetime"]=>
      NULL
      ["delivery_status"]=>
      string(4) "24hr"
      ["stock"]=>
      string(1) "0"
      ["status"]=>
      NULL
      ["discon"]=>
      string(1) "0"
      ["product_desc"]=>
      string(0) ""
      ["model_num"]=>
      string(8) "ATH-BT03"
      ["rating"]=>
      string(0) ""
      ["recycle_id"]=>
      array(2) {
        [0]=>
        string(1) "5"
        [1]=>
        string(2) "20"
      }
    }
    }
    ["doc:private"]=>
    object(DOMDocument)#5 (0) {
    }
  }
}
Ray
  • 2,713
  • 3
  • 29
  • 61
hkvega01
  • 3
  • 2

3 Answers3

0

Looks like a pretty weirdly mixed object.

If I'm following correctly, it's an array that contains an object that has a property named _param that is an array with the key cid.

$item[0]->_param['cid']

vicTROLLA
  • 1,554
  • 12
  • 15
0

The _param member is declared as protected, and can only be accessed from within the class itself, or from parent or inherited classes. The way to access this variable from outside of the class is to create and call a "getter" method, which would look like:

function getCid() {
    return $this->_param['cid'];
}
Jeff
  • 6,643
  • 3
  • 25
  • 35
  • No. This is not the way. If it was possible it would defeat the purpose oh having protected members, wouldn't it? Look up `Reflection` classes instead. – Mchl Aug 16 '11 at 07:53
  • How about a class that has a member whose value needs to be read-only to everything but itself/owners? Having a getter method is perfectly justifiable for this, is it not? – Jeff Aug 16 '11 at 08:29
  • That is correct, but the getter method must also be a member of this class. Maybe in that's what you meant actually. I might have misunderstood. – Mchl Aug 16 '11 at 08:33
  • Of course that's what I meant, I was a bit unclear though. I also made an inappropriate assumption that hkvega01 had access to the class source. The question doesn't state if they have access or not, so I shouldn't have assumed so. – Jeff Aug 16 '11 at 08:40
  • 1
    The object is `__PHP_Incomplete_Class_Name` type which usually means it's a object loaded from session or otherwise serialized, but the actual class code has not been loaded upon deserialization. – Mchl Aug 16 '11 at 08:56
0

Class property _param is protected and you can't get access to this one from outside. Try to use reflection. You can find how to make private/protected property is public here http://mark-story.com/posts/view/using-the-php-reflection-api-for-fun-and-profit. May be it helps.

Andrej
  • 7,474
  • 1
  • 19
  • 21