1--TEST-- 2Test tempnam() function: usage variations - Using previous unique filename 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--SKIPIF-- 6<?php 7if(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 14$file_path = __DIR__; 15 16echo "\n*** Test tempnam(): by passing previously created filenames ***\n"; 17$file_name = "tempnam_variation6.tmp"; 18for($i=1; $i<=3; $i++) { 19 echo "-- Iteration $i --\n"; 20 $file_name = tempnam("$file_path", $file_name); 21 22 if( file_exists($file_name) ) { 23 echo "File name is => "; 24 print($file_name); 25 echo "\n"; 26 27 echo "File created in => "; 28 $file_dir = dirname($file_name); 29 30 if ($file_dir == sys_get_temp_dir()) { 31 echo "temp dir\n"; 32 } 33 else if ($file_dir == $file_path) { 34 echo "directory specified\n"; 35 } 36 else { 37 echo "unknown location\n"; 38 } 39 } 40 41 unlink($file_name); 42} 43 44echo "\n*** Done ***\n"; 45?> 46--EXPECTF-- 47*** Test tempnam(): by passing previously created filenames *** 48-- Iteration 1 -- 49File name is => %s%et%s 50File created in => directory specified 51-- Iteration 2 -- 52File name is => %s%et%s 53File created in => directory specified 54-- Iteration 3 -- 55File name is => %s%et%s 56File created in => directory specified 57 58*** Done *** 59