I\'m trying to read a file line by line. The problem is the file was too big(over 500000 line) and I reach out the memory limit. I wonder how to read the file without being
You can use readfile and ob_get_level to manage memory and output buffering.
readfile() will not present any memory issues, even when sending large files, on its own. If you encounter an out of memory error ensure that output buffering is off with ob_get_level().
You may still have PHP output buffering active while performing the read.
Check that with:
You can use the following at the start of your script to stop output buffering if it's already started:
if (ob_get_level()) {
ob_end_clean();
}