fwrite.phpt 606 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. fwrite() tests
  3. --FILE--
  4. <?php
  5. $filename = __DIR__."/fwrite.dat";
  6. $fp = fopen($filename, "w");
  7. var_dump(fwrite($fp, ""));
  8. fclose($fp);
  9. $fp = fopen($filename, "r");
  10. var_dump(fwrite($fp, "data"));
  11. $fp = fopen($filename, "w");
  12. var_dump(fwrite($fp, "data", -1));
  13. var_dump(fwrite($fp, "data", 100000));
  14. fclose($fp);
  15. var_dump(fwrite($fp, "data", -1));
  16. var_dump(file_get_contents($filename));
  17. @unlink($filename);
  18. echo "Done\n";
  19. ?>
  20. --EXPECTF--
  21. int(0)
  22. Notice: fwrite(): Write of 4 bytes failed with errno=9 Bad file descriptor in %s on line %d
  23. bool(false)
  24. int(0)
  25. int(4)
  26. int(0)
  27. string(4) "data"
  28. Done