3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pathA = '/tmp/a.txt'; $pathB = '/tmp/b.txt'; file_put_contents($pathA, 'X'); file_put_contents($pathB, 'X'); $handleA = fopen($pathA, 'a+'); $handleB = fopen($pathB, 'a+'); assert(fwrite($handleA, 'Y') === fwrite($handleB, 'Y')); fseek($handleA, ftell($handleA)); // THIS LINE SHOULD DO NOTHING BUT CHANGES THE BEHAVIOR assert(ftell($handleA) === ftell($handleB)); $contentA = fread($handleA, 100); $contentB = fread($handleB, 100); var_dump($contentA); var_dump($contentB); assert($contentA === $contentB);
based on P8vQ9
Output for 8.0.0beta1 - rc2
string(1) "Y" string(0) "" Fatal error: Uncaught AssertionError: assert($contentA === $contentB) in /in/gTXsR:22 Stack trace: #0 /in/gTXsR(22): assert(false, 'assert($content...') #1 {main} thrown in /in/gTXsR on line 22
Process exited with code 255.
Output for 7.0.0 - 7.0.15, 7.0.17 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.19, 7.2.21 - 7.2.33, 7.3.0 - 7.3.10, 7.3.12 - 7.3.23, 7.4.0 - 7.4.11, 8.0.0alpha1 - alpha3
string(1) "Y" string(0) "" Warning: assert(): assert($contentA === $contentB) failed in /in/gTXsR on line 22
Output for 7.3.11
string(3) "YYY" string(1) "Y" Warning: assert(): assert($contentA === $contentB) failed in /in/gTXsR on line 22
Output for 7.2.20
string(0) "" string(0) ""
Output for 7.0.16
string(2) "YY" string(0) "" Warning: assert(): assert($contentA === $contentB) failed in /in/gTXsR on line 22
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.13, 5.3.15 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
string(1) "Y" string(0) "" Warning: assert(): Assertion failed in /in/gTXsR on line 22
Output for 5.3.14
string(2) "YY" string(0) "" Warning: assert(): Assertion failed in /in/gTXsR on line 22
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: file_put_contents() in /in/gTXsR on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: file_put_contents() in /in/gTXsR on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: file_put_contents() in /in/gTXsR on line 6