What is the purpose of using the `filesize()` function in PHP and what potential pitfalls should be aware of?

The `filesize()` function in PHP is used to retrieve the size of a file in bytes. This can be useful for various purposes such as checking file size before uploading, limiting file size, or displaying file size information to users. However, it's important to be aware that the function may return false if the file does not exist or if there are permission issues, so it's important to handle these cases appropriately in your code.

$filename = 'example.txt';

if (file_exists($filename)) {
    $filesize = filesize($filename);
    echo "The size of $filename is $filesize bytes.";
} else {
    echo "File $filename does not exist.";
}