unlink_variation6.phpt 945 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Test unlink() function : variation
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --FILE--
  6. <?php
  7. /* Prototype : bool unlink(string filename[, context context])
  8. * Description: Delete a file
  9. * Source code: ext/standard/file.c
  10. * Alias to functions:
  11. */
  12. echo "*** Testing unlink() : variation: contexts and relative files ***\n";
  13. // test relative directories and stream contexts.
  14. $subdir = 'subdir';
  15. $testfile = $subdir.'/testfile.txt';
  16. mkdir($subdir);
  17. touch($testfile);
  18. f_exists($testfile);
  19. $context = stream_context_create();
  20. var_dump(unlink($testfile, $context));
  21. f_exists($testfile);
  22. rmdir($subdir);
  23. function f_exists($file) {
  24. if (file_exists($file) == true) {
  25. echo "$file exists\n";
  26. }
  27. else {
  28. echo "$file doesn't exist\n";
  29. }
  30. }
  31. ?>
  32. ===DONE===
  33. --EXPECTF--
  34. *** Testing unlink() : variation: contexts and relative files ***
  35. subdir/testfile.txt exists
  36. bool(true)
  37. subdir/testfile.txt doesn't exist
  38. ===DONE===