What are the potential memory limitations when working with large files in PHP, such as a 100 MB file?

When working with large files in PHP, such as a 100 MB file, one potential memory limitation is running out of memory due to trying to load the entire file into memory at once. To solve this issue, you can read the file line by line or in chunks to minimize memory usage.

$filename = "large_file.txt";
$handle = fopen($filename, "r");

if ($handle) {
    while (($line = fgets($handle)) !== false) {
        // Process each line of the file here
    }

    fclose($handle);
} else {
    echo "Error opening the file.";
}