How can the file size be accurately determined and used to empty a file in PHP?

To accurately determine the file size in PHP, you can use the `filesize()` function which returns the size of a file in bytes. To empty a file, you can use `file_put_contents()` with an empty string as the content parameter.

// Get the file size
$file = 'example.txt';
$fileSize = filesize($file);

// Empty the file
file_put_contents($file, '');