unlink_variation2.phpt 860 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Test unlink() function : usage variations - unlink file in use
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) == 'WIN') {
  6. die('skip only on Linux');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : bool unlink ( string $filename [, resource $context] );
  12. Description : Deletes filename
  13. */
  14. /* Try to unlink file when file handle is still in use */
  15. $file_path = dirname(__FILE__);
  16. echo "*** Testing unlink() on a file which is in use ***\n";
  17. // temp file name used here
  18. $filename = "$file_path/unlink_variation2.tmp";
  19. // create file
  20. $fp = fopen($filename, "w");
  21. // try unlink() on $filename
  22. var_dump( unlink($filename) ); // expected: true on linux
  23. var_dump( file_exists($filename) ); // confirm file is deleted
  24. // now close file handle
  25. fclose($fp);
  26. echo "Done\n";
  27. ?>
  28. --EXPECTF--
  29. *** Testing unlink() on a file which is in use ***
  30. bool(true)
  31. bool(false)
  32. Done