unlink_basic.phpt 996 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Testing unlink() function : basic functionality
  3. --FILE--
  4. <?php
  5. $file_path = __DIR__;
  6. echo "*** Testing unlink() on a file ***\n";
  7. $filename = "$file_path/unlink_basic.tmp"; // temp file name used here
  8. $fp = fopen($filename, "w"); // create file
  9. fwrite($fp, "Hello World");
  10. fclose($fp);
  11. // delete file
  12. var_dump( unlink($filename) );
  13. var_dump( file_exists($filename) ); // confirm file doesn't exist
  14. echo "\n*** Testing unlink() : checking second argument ***\n";
  15. // creating a context
  16. $context = stream_context_create();
  17. // temp file name used here
  18. $filename = "$file_path/unlink_basic.tmp";
  19. $fp = fopen($filename, "w"); // create file
  20. fclose($fp);
  21. // delete file
  22. var_dump( unlink($filename, $context) ); // using $context in second argument
  23. var_dump( file_exists($filename) ); // confirm file doesn't exist
  24. echo "Done\n";
  25. ?>
  26. --EXPECT--
  27. *** Testing unlink() on a file ***
  28. bool(true)
  29. bool(false)
  30. *** Testing unlink() : checking second argument ***
  31. bool(true)
  32. bool(false)
  33. Done