|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2018-08-27 18:33 UTC] david at grudl dot com
 Description:
------------
In this code is file pointer changed in PHP 7.3
Test script:
---------------
$f = fopen('test', 'w');
fwrite($f, 'Hello');
ftruncate($f, 2); // in 7.3 changes file pointer to 2
fwrite($f, 'World');
fclose($f);
echo file_get_contents('test');
Expected result:
----------------
Should return "He\x00\x00\x00World"
Actual result:
--------------
'HeWorld'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 18:00:01 2025 UTC | 
I don't see any change in behavior. You shouldn't actually see "\x00" in any output. Whether you would see anything at all for those NULs depends. echo addslashes(file_get_contents('test'));