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