Home >Backend Development >PHP Tutorial >Solve the error problem of using Alipay SDK in PHP

Solve the error problem of using Alipay SDK in PHP

藏色散人
藏色散人forward
2019-11-12 14:15:363649browse

Recently, the company transferred some projects to the server. Later, it was discovered that an error occurred when using Alipay to pay. The error was as follows:

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

Finally, it was found that this was due to the php version of our new server being installed with php7.2. , due to the each method being abandoned in the php7.2 version, an error occurred. The solution is to change the each method to the foreach method, as follows:

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

is changed to:

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

After the modification is completed, the payment is found. The following error occurs:

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

This is an error caused by the count method parameter in php7.2 only supporting arrays. Modify as follows:

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

to:

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

After the modification is completed, Alipay payment is successful! ! !

Related recommendations: "PHP Tutorial"

The above is the detailed content of Solve the error problem of using Alipay SDK in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete