3v4l.org

run code in 300+ PHP versions simultaneously
<?php $txt = <<<TXT 1 Hello! 2 How 3 are 4 you? TXT; $file = new SplFileObject('php://memory', 'w+'); $file->fwrite($txt); echo 'Seeking line 1...', PHP_EOL; $file->seek(0); echo 'Position in the file: ', $file->ftell(), PHP_EOL; echo 'Rest of the file: ', PHP_EOL, $file->fread(5000); echo PHP_EOL, '-------------', PHP_EOL; echo 'Seeking line 2...', PHP_EOL; $file->seek(1); echo 'Position in the file: ', $file->ftell(), PHP_EOL; echo 'Rest of the file: ', PHP_EOL, $file->fread(5000);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
Seeking line 1... Position in the file: 0 Rest of the file: 1 Hello! 2 How 3 are 4 you? ------------- Seeking line 2... Position in the file: 9 Rest of the file: 2 How 3 are 4 you?
Output for 7.1.26 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0
Seeking line 1... Position in the file: 0 Rest of the file: 1 Hello! 2 How 3 are 4 you? ------------- Seeking line 2... Position in the file: 15 Rest of the file: 3 are 4 you?

preferences:
91.8 ms | 408 KiB | 5 Q