Reputation: 67868
I feel silly for asking, but how do I get plan
value in this object? _object
is protected, so PHP telling me I cannot. I am using the PHP library for Recurly.
object(Recurly_SubscriptionList)#47 (7) {
["_etag":"Recurly_Pager":private]=> NULL
["_position":"Recurly_Pager":private]=>int(0)
["_count":"Recurly_Pager":private]=>NULL
["_objects":protected]=> array(1) {
[0]=> object(Recurly_Subscription)#50 (6) {
["_values":protected]=> array(11) {
["subscription_add_ons"]=> array(0) {}
["account"]=> object(Recurly_Stub)#54 (4) {
["objectType"]=> string(7) "account"
["_href":protected]=> string(37) "https://api.recurly.com/v2/accounts/1"
["_client":protected]=>NULL
["_links":protected]=>array(0) {}
}
["plan"]=> hello
Upvotes: 2
Views: 410
Reputation: 67868
So since I come from a Java background, I was expecting a getVar()
function. It turns out that PHP's Magic Method __get()
allows me to just access it normally IF you overload your __get()
properly.
So in specific to this case, for whoever that may stumble on to this, if you are using the Recurly PHP Library, you have to use foreach
to get to the objects and then just access plan
normally.
For example,
Let's say the object above was the value of the variable $subscriptions
:
foreach($subscriptions as $subscription) {
echo $subscription->plan;
}
Upvotes: 2
Reputation: 522024
There has to be some sort of object method that returns the data to you. Read the class documentation.
Upvotes: 1