简体   繁体   中英

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

I have migrated to a new server which is using PHP v7 (from my PHP v5.4) and am now being displayed errors on my website.

This is the lines of code which is returning the error:

// The value of $ip at this point would look something like: "192.0.34.166"
$ip = ip2long($ip);
// The $ip would now look something like: 1073732954
if(!count($ip) > 0 || !preg_match('/^\d+$/', $ip) || empty($ip)) {
    $ip="0000000000";
}

How can I resolve this?

ip2long never returned an array. I think you can safely remove !count($ip) > 0 || from your condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM