1--TEST-- 2Bug #76803 ftruncate changes file pointer 3--FILE-- 4<?php 5 6$fn = __DIR__ . DIRECTORY_SEPARATOR . "test76803"; 7 8$f = fopen($fn, "w"); 9fwrite($f, "Hello"); 10ftruncate($f, 2); 11fwrite($f, "World"); 12fclose($f); 13var_dump(addslashes(file_get_contents($fn))); 14 15$f = fopen($fn, "w"); 16fwrite($f, "Hello"); 17ftruncate($f, 2); 18fclose($f); 19var_dump(addslashes(file_get_contents($fn))); 20 21$f = fopen('php://memory', 'w+'); 22fwrite($f, 'Hello'); 23ftruncate($f, 2); // in 7.3 changes file pointer to 2 24fwrite($f, 'World'); 25rewind($f); 26var_dump(addslashes(stream_get_contents($f))); 27fclose($f); 28 29?> 30--CLEAN-- 31<?php 32$fn = __DIR__ . DIRECTORY_SEPARATOR . "test76803"; 33unlink($fn); 34?> 35--EXPECT-- 36string(13) "He\0\0\0World" 37string(2) "He" 38string(7) "HeWorld" 39