PHP函数和编码结果到JSON中

I'm trying to call a function and pass the result in a json object in PHP. Everything is working fine except the function part. I keep getting an error of End of Input at Character 1 of.

Here's the line that's causing me trouble

$ImageCount =  getCount($fullName);
$response["count"] = $ImageCount;

Here's the full file:

<?php
$response = array();

include 'db/db_connect.php';
include 'functions.php';

$inputJSON = file_get_contents('php://input');

//Get the input request parameters
$input = json_decode($inputJSON, TRUE); //convert JSON into array

//Check for Mandatory parameters
if(isset($input['username']) && isset($input['password'])){
    $username = $input['username'];
    $password = $input['password'];
    $query    = "SELECT full_name,password_hash, salt FROM member WHERE username = ?";

    if($stmt = $con->prepare($query)){
        $stmt->bind_param("s",$username);
        $stmt->execute();
        $stmt->bind_result($fullName,$passwordHashDB,$salt);
        if($stmt->fetch()){

            //Validate the password
            if(password_verify(concatPasswordWithSalt($password,$salt),$passwordHashDB)){
            $ImageCount =  getCount($fullName);
            $response["status"] = 0;
            $response["message"] = "Login successful";
            $response["full_name"] = $fullName;
            $response["count"] = $ImageCount;
        }else{
            $response["status"] = 1;
            $response["message"] = "Invalid username and password combination";
        }
    }else{
        $response["status"] = 1;
        $response["message"] = "Invalid username and password combination";
    }

    $stmt->close();
    }
}else{
    $response["status"] = 2;
    $response["message"] = "Missing mandatory parameters";
}
//Display the JSON response
echo json_encode($response);
?>

My getCount() function code:

function getCount($fname){
    global $count;
    $path = 'MobileApp/Images/'; 
    $slash = '/';
    $fullpath = $path.$fname.$slash;
    //echo $fullpath;
    $fi = new FilesystemIterator($fullpath, FilesystemIterator::SKIP_DOTS);
    $count = (iterator_count($fi));
    return $count;
}

I think problem lies in the getCount() function.

PHP supports count() to get number of elements in the array.

count

(PHP 4, PHP 5, PHP 7)

count — Count all elements in an array, or something in an object
Description
count ( mixed $array_or_countable [, int $mode = COUNT_NORMAL ] ) : int

Please check https://www.php.net/manual/en/function.count.php