<?php /* 1. Create a file called test.txt 2. Zip that file into a file called test.zip 3. Uncomment the last line in this code 4. Run this code against PHP 7.4, 8.0 and 8.1 5. Note that 8.1 throws an exception */ class XYZ { private function getFilePointer($file) { $zip = new ZipArchive(); if (!$zip->open($file)) { throw new Exception("error"); } $fileName = 'test.txt'; if (!($stream = $zip->getStream($fileName))) { throw new Exception("error"); } return $stream; } public function doWork() { $stream = $this->getFilePointer('test.zip'); fgetcsv($stream); } } // Uncomment to run // (new XYZ())->doWork();
You have javascript disabled. You will not be able to edit any code.