SplFileObject is faster than fopen/fgets

I had some memory issues recently when reading a file line-by-line with PHP. So I found that SplFileObject is faster and uses less memory than fopen followed by a loop with fgets. Here is a simple before & after code: Before $handle = fopen($path, ‘r’); if ($handle) { while (($buffer = fgets($handle, 1024)) !== false) […]