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.12, 8.1rc1 - rc3
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.31, 7.4.0 - 7.4.25, 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:
48.46 ms | 461 KiB | 5 Q