What is the difference between
$contents = file_get_contents("folder/somefile.txt")
and
$handle = fopen("folder/somefile.txt", "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
in terms of performance, file pointer handling and memory managing ?
And is it true that file_get_contents uses mmap
if OS allows it ?
fread has a limit on how many chars you can read, and its better for parsing data.
file_get_contents has no limit on the input (that I know of). This is used for external API access and such.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With