What are the limitations of using PHP to determine file sizes on remote servers?

When using PHP to determine file sizes on remote servers, one limitation is that the function `filesize()` may not work for remote files accessed via HTTP or FTP. To overcome this limitation, you can use cURL to fetch the file size from the remote server headers.

function get_remote_file_size($url) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_exec($ch);
    $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
    curl_close($ch);
    return $size;
}

$remote_file_url = 'http://example.com/file.txt';
$file_size = get_remote_file_size($remote_file_url);
echo 'File size: ' . $file_size . ' bytes';