Note that if you specify a remote file (via a URL) to check the size of, PHP will first download the remote file to your server.
If you're using this function to check the size of user provided image links, this could constitute a security risk. A malicious user could potentially link to a very large image file and cause PHP to download it. I do not know what, if any, file size limits are in place for the download. But suppose the user provided a link to an image that was several gigabytes in size?
It would be nice if there were a way to limit the size of the download performed by this function. Hopefully there is already a default with some sensible limits.