What are the potential issues with using the filesize() function in PHP for checking file sizes?

Using the filesize() function in PHP for checking file sizes can be problematic as it may not work correctly for files larger than 2GB due to limitations with 32-bit systems. To solve this issue, you can use the stat() function which returns file information including the size, and it is not limited by the file size constraints of the filesize() function.

$file = 'example.txt';

$stat = stat($file);
$filesize = $stat['size'];

echo "File size: " . $filesize . " bytes";