tempnam_variation5-win32.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Test tempnam() function: usage variations - existing file
  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. /* Prototype: string tempnam ( string $dir, string $prefix );
  13. Description: Create file with unique file name.
  14. */
  15. /* Passing an existing file as $prefix for tempnam() fn */
  16. $file_path = dirname(__FILE__);
  17. echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
  18. $dir_name = $file_path."/tempnam_variation6";
  19. mkdir($dir_name);
  20. $h = fopen($dir_name."/tempnam_variation6.tmp", "w");
  21. for($i=1; $i<=3; $i++) {
  22. echo "-- Iteration $i --\n";
  23. $created_file = tempnam("$dir_name", "tempnam_variation6.tmp");
  24. if( file_exists($created_file) ) {
  25. echo "File name is => ";
  26. print($created_file);
  27. echo "\n";
  28. }
  29. else
  30. print("File is not created");
  31. unlink($created_file);
  32. }
  33. fclose($h);
  34. unlink($dir_name."/tempnam_variation6.tmp");
  35. rmdir($dir_name);
  36. echo "\n*** Done ***\n";
  37. ?>
  38. --EXPECTF--
  39. *** Test tempnam() function: by passing an existing filename as prefix ***
  40. -- Iteration 1 --
  41. File name is => %stempnam_variation6%et%s
  42. -- Iteration 2 --
  43. File name is => %stempnam_variation6%et%s
  44. -- Iteration 3 --
  45. File name is => %stempnam_variation6%et%s
  46. *** Done ***