How does PHP's integer type and platform limitations affect functions like filesize() for files larger than 2GB?

PHP's integer type is platform-dependent, meaning that the maximum value an integer can hold varies based on the platform. This can cause issues when working with files larger than 2GB, as the filesize() function returns an integer representing the file size. To handle files larger than 2GB, you can use the bcdiv() function from the BC Math extension to accurately calculate the file size.

function getFileSize($file) {
    $size = trim(shell_exec('stat -c %s ' . escapeshellarg($file)));
    return $size;
}