Isset不使用对象的内容

时间:2015-06-19 05:44:48

标签: php

当我打印它时我有$list然后我得到以下输出

AWeberEntry Object
(
[_privateData:protected] => Array
    (
        [0] => resource_type_link
        [1] => http_etag
    )

[_localDiff:protected] => Array
    (
    )

[_collections:protected] => Array
    (
    )

[adapter] => OAuthApplication Object
    (
        [debug] => 
        [userAgent] => AWeber OAuth Consumer Application 1.0 - https://labs.aweber.com/
        [format] => 
        [requiresTokenSecret] => 1
        [signatureMethod] => HMAC-SHA1
        [version] => 1.0
        [curl] => CurlObject Object
            (
            )

        [user] => OAuthUser Object
            (
                [authorizedToken] => 
                [requestToken] => 
                [verifier] => 
                [tokenSecret] => BoPWmqWup6T1oAJAS0BJnKkN830iebnruCQ9I2FL
                [accessToken] => AgJbZty67Z4w1uByP728Ybsr
            )

        [consumerKey] => AkaXl8e3tPa3urnbNI4YvBYQ
        [consumerSecret] => kVGhArLuQT8iY4qMJ94dAk9nmWonKRuKHEBhpa2r
        [app] => AWeberServiceProvider Object
            (
                [baseUri] => https://api.aweber.com/1.0
                [accessTokenUrl] => https://auth.aweber.com/1.0/oauth/access_token
                [authorizeUrl] => https://auth.aweber.com/1.0/oauth/authorize
                [requestTokenUrl] => https://auth.aweber.com/1.0/oauth/request_token
            )

    )

[data] => Array
    (
        [total_unconfirmed_subscribers] => 0
        [total_subscribers_subscribed_yesterday] => 0
        [unique_list_id] => awlist3561167
        [http_etag] => "0f9b24fd3d578a7fa402bda6cf029732c2ae9dba-ca5feee2b7fbb6febfca8af5541541ea960aaedb"
        [web_form_split_tests_collection_link] => https://api.aweber.com/1.0/accounts/390249/lists/3561167/web_form_split_tests
        [subscribers_collection_link] => https://api.aweber.com/1.0/accounts/390249/lists/3561167/subscribers
        [total_subscribers_subscribed_today] => 0
        [id] => 3561167
        [total_subscribed_subscribers] => 519
        [total_unsubscribed_subscribers] => 22
        [campaigns_collection_link] => https://api.aweber.com/1.0/accounts/390249/lists/3561167/campaigns
        [custom_fields_collection_link] => https://api.aweber.com/1.0/accounts/390249/lists/3561167/custom_fields
        [self_link] => https://api.aweber.com/1.0/accounts/390249/lists/3561167
        [total_subscribers] => 541
        [resource_type_link] => https://api.aweber.com/1.0/#list
        [web_forms_collection_link] => https://api.aweber.com/1.0/accounts/390249/lists/3561167/web_forms
        [name] => 7affsubniche
    )

[_dynamicData] => Array
    (
    )

[url] => /accounts/390249/lists/3561167
)

现在我使用

echo $list->unique_list_id;

然后它显示我正确的输出。但是当我尝试

if(isset($list->unique_list_id)) {

} else {
        echo 'check 1';
}
然后它总是出现在其他条件下。虽然unique_list_id中设置了$list。我也试过了property_exists,但它也没有用。

所以我的问题是如何将isset用于对象数据。

2 个答案:

答案 0 :(得分:3)

我看到您的unique_list_id位于data属性中。所以你可以用以下方法检查:

if(isset($list->data['unique_list_id'])) {
    // do something
} else {
    // do another one
}

答案 1 :(得分:2)

我认为你的对象有一个def foo a, s, e a = e < s ? (a[s,a.size] << a[0..e]).flatten : a[s..e] end a = [7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6] a = foo(a, 6, 0) # => [1, 2, 3, 4, 5, 6, 7] a = foo(a, 4, 9) # => [11, 12, 1, 2, 3, 4] 方法,这就是你第一次调用的原因。您还需要实现__get ()方法

__isset ()