简体   繁体   中英

Access private object property

I'm using SabreAMF to decode AMF data in PHP. I'm getting result as :

Rtmp\SabreAMF\AMF3\SabreAMF_AMF3_Wrapper Object
(
    [data:Rtmp\SabreAMF\AMF3\SabreAMF_AMF3_Wrapper:private] => Array
    (
      [0] => Array
      (
        [0] => value1
        [1] => value2
      ...

The problem is that I can't access data property to get an Array with values because it's a private property. How can i do it ?

The general idea of private members is that they are blocked from being accessed from outside.

If you have access to the class, you can write a __get method which will help you (but if you have the access you can also make them public).

Some workaround is to "catch" the output of print_r , var_export or var_dump functions and then parse it, so you would get what you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM