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

藏色散人
Release: 2023-04-07 19:20:02
forward
3650 people have browsed it

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
Copy after login

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)) {}
Copy after login

is changed to:

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

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
Copy after login

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);
Copy after login

to:

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

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!

Related labels:
php
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template