How can PHP be optimized to avoid exceeding memory limits when reading large video files for streaming?

When reading large video files for streaming in PHP, it's important to optimize memory usage to avoid exceeding limits. One way to achieve this is by using streaming techniques such as reading and outputting the file in chunks rather than loading the entire file into memory at once. This can be done using functions like `fopen`, `fread`, and `echo` to read and output the file in manageable portions.

$videoFilePath = 'path/to/video.mp4';

$handle = fopen($videoFilePath, 'rb');

while (!feof($handle)) {
    echo fread($handle, 8192);
    ob_flush();
    flush();
}

fclose($handle);