【发布时间】:2020-08-27 22:17:06
【问题描述】:
我刚刚将我的 PHP 版本从 5.6 升级到了 7.4。我在我的页面中使用了 count() 函数,例如:
$watch_server_count = count($watch_server);
if ($watch_server_count > 0) {
foreach ($watch_server->table as $key=> $watch_server_rows) {
}
}
警告:count():参数必须是数组或实现了Countable的对象...
【问题讨论】:
-
检查
$watch_server包含的内容。 -
$watch_server是一个对象,而不是一个数组,因此是$watch_server->...。你是说$watch_server_count = count($watch_server->table);吗?这是有道理的,因为您正在迭代此属性 -
object(ShinoDB)#6137 (3) { ["error"]=> NULL ["filename"]=> string(187) "OK^ok.ru/videoembed/963440478908 Vidbom^vidbm.com/embed-qx0qzffbptht.html Vevio^ vev.io/embed/k4rdekk1q2o1 Vidshare^vidshare.tv/embed-l8w79d88qq1v.html" ["table"]=> array(4) { [0]=> array(2) { [0]=> string(2) "OK" [1]=> string( 37) "ok.ru/videoembed/963440478908" } } }
-
这能回答你的问题吗? PHP count replacement
标签: php count php-7 php-7.4 countable