解決php使用支付寶SDK報錯問題

 

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

 

1web

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

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

1php7

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

改爲:3d

1code

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

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

1

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

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

1

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

改爲:

1

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

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

相關文章
相關標籤/搜索