tempnam_variation5-win32.phpt 1.2 KB

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