php 使用支付寶SDK報錯解決

最近公司將一些項目轉移了服務器,後來發現使用支付寶支付時發現出現錯誤,錯誤以下:php

The each() function is deprecated. This message will be suppressed on furthe

最後發現這是因爲咱們的新服務器的php版本安裝的時php7.2,因爲php7.2版本廢棄了each方法致使出現錯誤,解決方法爲將each方法改爲foreach方法,以下將:數組

while (list($key, $val) = each($para)) {}

改爲:服務器

foreach ($para as $key => $val) {}

修改完成支付又發現出現以下錯誤:php7

count(): Parameter must be an array or an object that implements Countable

這是因爲在php7.2中count方法參數只支持數組致使的錯誤,修改以下將:code

$arg = substr($arg,0,count($arg)-2);

改爲:支付寶

$arg = substr($arg,0,strlen($arg)-1);

修改完成以後支付寶支付成功!!!io

相關文章
相關標籤/搜索