doc-en
doc-en copied to clipboard
Fix function flock example
When I fwrite
after ftruncate
, the control characters
has appended.
You can reproduce this by:
$fp = fopen("file.txt", "r+b");
ftruncate($fp, 0);
// rewind($fp);
fwrite($fp, "contents");
Also I can confirm that do rewind
after ftruncate
would fix the issue, therefore this PR is for it.
References:
- https://www.php.net/manual/en/function.ftruncate.php
- https://www.php.net/manual/en/function.flock.php#116782
- https://stackoverflow.com/questions/18255780/fwrite-writes-nul