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