• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
8 views

Problem:

warning: count(): parameter must be an array or an object that implements countable in

I am using count() function in my PHP application. I have also switched to latest version ie  7.2 from 5.6 of PHP.

by (550 points)  

1 Answer

0 votes

Solution:

Note that count() is only allowed in objects and arrays in latest PHP ie  7.2 onwards.

Code Example:

function dprint_r($input, $return = FALSE, $name = NULL, $function = 'print_r', $check= TRUE) {

    if (user_access('access devel information')) {

      ...

-     if (count($input, COUNT) > testVal) {

+     if ((is_object($input) || is_array($input)) && count($input, COUNT) > testVal) {

     

        $printed_value = "<textarea rows=30 style=\"width: 100%;\">\n" . $name . $output . '</textarea>';

      }

      else {

        $printed_value = '<pre>' . $name . $output . '</pre>';

      }

      ...

    }

  }

by (3.2k points)  
...