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