fgetc_variation2.phpt 777 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. Test fgetc() function : usage variations - closed handle
  3. --FILE--
  4. <?php
  5. /* try reading a char using fgetc() using invalid handles
  6. - closed file handle
  7. - unset file handle
  8. */
  9. // include the header for common test function
  10. include ("file.inc");
  11. echo "*** Testing fgetc() : usage variations ***\n";
  12. echo "-- Testing fgetc() with closed handle --\n";
  13. // open the file for reading
  14. $file_handle = fopen(__FILE__, "r");
  15. // close the file
  16. fclose($file_handle);
  17. // read from closed file
  18. try {
  19. var_dump( fgetc($file_handle) );
  20. } catch (TypeError $e) {
  21. echo $e->getMessage(), "\n";
  22. }
  23. echo "Done";
  24. ?>
  25. --EXPECT--
  26. *** Testing fgetc() : usage variations ***
  27. -- Testing fgetc() with closed handle --
  28. fgetc(): supplied resource is not a valid stream resource
  29. Done