I have an error message in my php script

mrcodesmrcodes Posts: 92
edited May 2019 in PHP

Hello guys, I have an issue: I'm getting this error message below on my script:


Warning: count(): Parameter must be an array or an object that implements Countable in /home/advaaxrv/test.pee.ng/models/Analytics.php on line 19

 lie 19

and this is the lines below:

12. public static function getData($link) {
13. $analytics = new self;
14. $data = $analytics::sel_table(self::$table)->find(['link_id' => $link->id]);
15.
16. $analytics::$data = $data;
17.
18. // TOTAL NUMBER OF VISITS
19. $analytics->total_visits = count($data);
20.
21. // LAST VISIT DATE
22. $last_analytic_data = array_reverse($data);
23. $analytics->last_visit = date("jS M, Y, h:i a", strtotime(array_shift($last_analytic_data)->date));
24.
25. return $analytics;
26. }
It notice this works perfectly on my local server running PHP 7.1.9 but fails on my production server running PHP 7.2 and upon changing my production server from to 7.1.* it works well...


Is it that there's another way of calling the count function on Objects/Arrays in 7.2?

Comments

Sign In or Register to comment.