3v4l.org

run code in 300+ PHP versions simultaneously
<?php $f = new SplFileObject('php://memory', 'r+'); assert('$f instanceof Iterator'); $f->fwrite("line 1"); $f->rewind(); assert('$f->valid() === true'); assert('$f->eof() === false'); assert('$f->current() === "line 1"'); //assert('$f->valid() === true'); // fails assert('$f->eof() === true');
Output for 5.1.4 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.3.32 - 7.3.33, 7.4.26, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/85V3S on line 4 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/85V3S on line 7 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/85V3S on line 8 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/85V3S on line 9 Deprecated: assert(): Calling assert() with a string argument is deprecated in /in/85V3S on line 11
Output for 5.1.3
<br /> <b>Fatal error</b>: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(php://memory) [&lt;a href='function.SplFileObject---construct'&gt;function.SplFileObject---construct&lt;/a&gt;]: failed to open stream: Inappropriate ioctl for device' in /in/85V3S:3 Stack trace: #0 /in/85V3S(3): SplFileObject-&gt;__construct('php://memory', 'r+') #1 {main} thrown in <b>/in/85V3S</b> on line <b>3</b><br />
Process exited with code 255.
Output for 5.1.2
<br /> <b>Fatal error</b>: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(php://memory) [&lt;a href='function.--construct'&gt;function.--construct&lt;/a&gt;]: failed to open stream: Inappropriate ioctl for device' in /in/85V3S:3 Stack trace: #0 /in/85V3S(3): SplFileObject-&gt;__construct('php://memory', 'r+') #1 {main} thrown in <b>/in/85V3S</b> on line <b>3</b><br />
Process exited with code 255.
Output for 5.1.0 - 5.1.1
<br /> <b>Fatal error</b>: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(php://memory) [<a href='function.--construct'>function.--construct</a>]: failed to open stream: Inappropriate ioctl for device' in /in/85V3S:3 Stack trace: #0 /in/85V3S(3): SplFileObject->__construct('php://memory', 'r+') #1 {main} thrown in <b>/in/85V3S</b> on line <b>3</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Fatal error</b>: Class 'SplFileObject' not found in <b>/in/85V3S</b> on line <b>3</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: splfileobject in <b>/in/85V3S</b> on line <b>3</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: splfileobject in <b>/in/85V3S</b> on line <b>3</b><br />

preferences:
241.48 ms | 402 KiB | 374 Q