the php manual up front says to stream the file to a string. the abc.txt file is 1gb but if i specify the start and end with file_get_contents('abc.txt', false, NULL, 0, 36) it will load only the specified 0 to 36 bytes into memory or otherwise first load everything into memory and then display from 0 to 36?
According to the PHP interpreter source code ( GitHub , version 8.1), the function
file_get_contents
calls a native function, written in C, called_php_stream_copy_to_mem
and defined inmain/streams/streams.c
, which creates astring
the same size as the one sent by the fifth parameter offile_get_contents
, and reads the same amount of bytes of the file (or, generalizing,stream
), storing them in the created string.