-6

i am not able to get array from object:

please see my code below:

 print_r($product_ser_id);

Print result:

WHMCS\Service\Service Object
(
    [table:protected] => tblhosting
    [columnMap:protected] => Array
        (
            [clientId] => userid
            [productId] => packageid
            [serverId] => server
            [registrationDate] => regdate
            [paymentGateway] => paymentmethod
            [status] => domainstatus
            [promotionId] => promoid
            [overrideAutoSuspend] => overideautosuspend
            [overrideSuspendUntilDate] => overidesuspenduntil
            [bandwidthUsage] => bwusage
            [bandwidthLimit] => bwlimit
            [lastUpdateDate] => lastupdate
            [firstPaymentAmount] => firstpaymentamount
            [recurringAmount] => amount
            [recurringFee] => amount
        )
}

here i have to get value from [productId]

i have already tested as: $product_ser_id -> attributes:protected;

its show error as:

ParseError: syntax error, unexpected ':' in 

and i know there many example so please don't tell duplicate untill you really understand my issues.

Please help

thanks

Shiv Singh
  • 6,939
  • 3
  • 40
  • 50

1 Answers1

0

issues solved with the answer of @drewish

Source: ReflectionClass

Code:

 function accessProtected($obj, $prop) {
  $reflection = new ReflectionClass($obj);
  $property = $reflection->getProperty($prop);
  $property->setAccessible(true);
  return $property->getValue($obj);
}
Shiv Singh
  • 6,939
  • 3
  • 40
  • 50