<?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);
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- 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.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
- string(1) "Y"
string(0) ""
Warning: assert(): assert($contentA === $contentB) failed in /in/gTXsR on line 22
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
- string(1) "Y"
string(0) ""
Warning: assert(): Assertion failed in /in/gTXsR on line 22
preferences:
258.88 ms | 402 KiB | 335 Q