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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 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: 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:
194.24 ms | 402 KiB | 184 Q