ftruncate_bug77081.phpt 458 B

123456789101112131415161718192021222324
  1. --TEST--
  2. Bug #77081 ftruncate() changes seek pointer in c mode
  3. --FILE--
  4. <?php
  5. $filename = __DIR__ . DIRECTORY_SEPARATOR . "test77081";
  6. file_put_contents($filename, 'foo');
  7. $stream = fopen($filename, 'c');
  8. ftruncate($stream, 0);
  9. var_dump(ftell($stream));
  10. fwrite($stream, 'bar');
  11. fclose($stream);
  12. var_dump(file_get_contents($filename));
  13. ?>
  14. --CLEAN--
  15. <?php
  16. $fn = __DIR__ . DIRECTORY_SEPARATOR . "test77081";
  17. unlink($fn);
  18. ?>
  19. --EXPECT--
  20. int(0)
  21. string(3) "bar"