tempnam_variation6-win32.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Test tempnam() function: usage variations - Using previous unique filename
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --SKIPIF--
  6. <?php
  7. if(substr(PHP_OS, 0, 3) != "WIN")
  8. die("skip Windows Only");
  9. ?>
  10. --FILE--
  11. <?php
  12. /* Trying to create unique files by passing previously created unique file name as prefix */
  13. $file_path = __DIR__;
  14. echo "\n*** Test tempnam(): by passing previously created filenames ***\n";
  15. $file_name = "tempnam_variation6.tmp";
  16. for($i=1; $i<=3; $i++) {
  17. echo "-- Iteration $i --\n";
  18. $file_name = tempnam("$file_path", $file_name);
  19. if( file_exists($file_name) ) {
  20. echo "File name is => ";
  21. print($file_name);
  22. echo "\n";
  23. echo "File created in => ";
  24. $file_dir = dirname($file_name);
  25. if ($file_dir == sys_get_temp_dir()) {
  26. echo "temp dir\n";
  27. }
  28. else if ($file_dir == $file_path) {
  29. echo "directory specified\n";
  30. }
  31. else {
  32. echo "unknown location\n";
  33. }
  34. }
  35. unlink($file_name);
  36. }
  37. echo "\n*** Done ***\n";
  38. ?>
  39. --EXPECTF--
  40. *** Test tempnam(): by passing previously created filenames ***
  41. -- Iteration 1 --
  42. File name is => %s%et%s
  43. File created in => directory specified
  44. -- Iteration 2 --
  45. File name is => %s%et%s
  46. File created in => directory specified
  47. -- Iteration 3 --
  48. File name is => %s%et%s
  49. File created in => directory specified
  50. *** Done ***