3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
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.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 />