Php 如何从该对象检索值?

Php 如何从该对象检索值?,php,stripe-payments,Php,Stripe Payments,使用php,我试图获得一个特定的优惠券 require_once './lib/Stripe.php'; Stripe::setApiKey(STRIPE_SK); $response = Stripe_Coupon::retrieve('coupon id here'); print_r($response); 打印(回复);把下面的东西给了我。我的问题是如何从对象中检索[id]?谢谢你的帮助 Stripe_Coupon Object ( [_apiKey:protected] =&

使用php,我试图获得一个特定的优惠券

require_once './lib/Stripe.php';
Stripe::setApiKey(STRIPE_SK);
$response = Stripe_Coupon::retrieve('coupon id here');
print_r($response);
打印(回复);把下面的东西给了我。我的问题是如何从对象中检索[id]?谢谢你的帮助

Stripe_Coupon Object
(
    [_apiKey:protected] => sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxx
    [_values:protected] => Array
        (
            [id] => 10percent
            [created] => 1395914393
            [percent_off] => 10
            [amount_off] => 
            [currency] => 
            [object] => coupon
            [livemode] => 
            [duration] => repeating
            [redeem_by] => 
            [max_redemptions] => 
            [times_redeemed] => 2
            [duration_in_months] => 12
            [valid] => 1
       )
)

该对象使用的是PHP magic\uuu get方法。您应该能够使用:

$id = $response->id;
如果您查看源代码,您会看到对象最终会归结为Stripe_对象类。资料来源:

您可以尝试
$response->\u values->id
或类似的方法。这不起作用。感谢您通过
$response->\u值[0]
提供的输入?试试看。它位于数组中的_值中。
$response->id
将起作用。条纹对象比打印时看到的对象更复杂