Is using exec() to access the file system a reliable method for retrieving file sizes in PHP?

Using `exec()` to access the file system in PHP can be risky as it relies on external commands and may not work on all server configurations. A more reliable method for retrieving file sizes in PHP is to use built-in functions like `filesize()` which directly interacts with the file system without the need for external commands.

$file = 'example.txt';
$fileSize = filesize($file);

if ($fileSize !== false) {
    echo "The size of $file is: $fileSize bytes";
} else {
    echo "Failed to retrieve file size.";
}