【问题标题】:How do I solve this PHP stripe deprecation error?如何解决此 PHP 条带弃用错误?
【发布时间】:2020-12-08 09:55:02
【问题描述】:

当用户尝试订阅时我收到此错误我应该怎么做才能解决这个问题?

错误异常 (E_ERROR)

array_key_exists():不推荐在对象上使用 array_key_exists()。 使用 isset() 或 property_exists() 代替(查看: /home/u511498974/domains/sendcheetah.com/public_html/emailmarketing/vendor/acelle/cashier/resources/views/stripe/checkout.blade.php)

以前的例外情况

array_key_exists():不推荐在对象上使用 array_key_exists()。 改用 isset() 或 property_exists() (0)

@LV98 $requestStartMs = Util\Util::currentTimeMillis();

    list($rbody, $rcode, $rheaders) = $this->httpClient()->request(
        $method,
        $absUrl,
        $rawHeaders,
        $params,
        $hasFile
    );

    if (array_key_exists('request-id', $rheaders)) {
        self::$requestTelemetry = new RequestTelemetry(
            $rheaders['request-id'],
            Util\Util::currentTimeMillis() - $requestStartMs
        );
    }

    return [$rbody, $rcode, $rheaders, $myApiKey];
}

/**
 * @param resource $resource
 * @param bool     $hasCurlFile
 *

【问题讨论】:

  • 请分享代码
  • 您的答案就在错误本身中:Use isset() or property_exists() instead

标签: php mysql stripe-payments


【解决方案1】:

正如PeterSH 在您问题下方的 cmets 中所提到的,如果您想检查类/对象的某些属性,您应该使用 property_exists() 而不是 array_key_exists() 的函数。 要确保您的属性具有值,请使用isset()

此示例将检查类/对象中是否存在属性并包含某些内容:

// You probably want to check, whether that property exists and does have a value other than null.
if (property_exists($yourClass, 'propertyName') && isset($yourClass->propertyName) {
  ... // Do something in here.
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    • 2012-02-14
    • 2015-04-12
    • 2016-06-21
    相关资源
    最近更新 更多