What best practices should be followed when using the filesize() function in PHP?

When using the `filesize()` function in PHP to get the size of a file, it is important to check if the file exists before calling the function to avoid potential errors. This can be done using the `file_exists()` function. Additionally, it is good practice to handle any potential errors or exceptions that may occur while attempting to get the file size.

$file = 'example.txt';

if(file_exists($file)){
    $size = filesize($file);
    echo "File size: " . $size . " bytes";
} else {
    echo "File does not exist.";
}