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