What are the advantages and disadvantages of using PHP's file_get_contents() function versus fopen/fread/fclose for reading a text file in a text scroller?

When reading a text file in a text scroller in PHP, using file_get_contents() is more concise and easier to use compared to fopen/fread/fclose. However, file_get_contents() loads the entire file into memory at once, which can be inefficient for large files. On the other hand, fopen/fread/fclose allows for more control over reading the file in chunks, which can be more memory-efficient for large files.

// Using file_get_contents()
$fileContents = file_get_contents('example.txt');
echo $fileContents;

// Using fopen/fread/fclose
$handle = fopen('example.txt', 'r');
while (!feof($handle)) {
    $chunk = fread($handle, 1024);
    echo $chunk;
}
fclose($handle);