Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in



PHP Snippet 1:

if (is_countable($aa) && count($aa) > 0) :

PHP Snippet 2:

count((array)$XYZVariable);

PHP Snippet 3:

if(isset($_POST["submit"])){
    @$subject = $_POST['subject'];
    @$term = $_POST['term'];
    @$session = $_POST['session'];
    @$size = count((array)$_POST['adm_num']));
    @$size = count((array)$_POST['ca1']));
    @$size = count((array)$_POST['ca2']));
    @$size = count((array)$_POST['ca3']));

    $i = 0;
    while ($i < $size) {
        $ca1= $_POST['ca1'][$i];
        $ca2= $_POST['ca2'][$i];
        $ca3= $_POST['ca3'][$i];
        $adm_num = $_POST['adm_num'][$i];
    }
}

PHP Snippet 4:

$ab = is_array($aa) ? count($aa) : 0 ;

PHP Snippet 5:

@$size = count($_POST['ca1']); 

PHP Snippet 6:

@$size = count((array)$_POST['ca1']);