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