2
Test tempnam() function: usage variations - existing file
5
if(substr(PHP_OS, 0, 3) == "WIN")
6
die("skip Do not run on Windows");
10
/* Prototype: string tempnam ( string $dir, string $prefix );
11
Description: Create file with unique file name.
14
/* Passing an existing file as $prefix for tempnam() fn */
16
$file_path = dirname(__FILE__);
18
echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
19
$dir_name = $file_path."/tempnam_variation6";
21
$h = fopen($dir_name."/tempnam_variation6.tmp", "w");
23
for($i=1; $i<=3; $i++) {
24
echo "-- Iteration $i --\n";
25
$created_file = tempnam("$dir_name", "tempnam_variation6.tmp");
27
if( file_exists($created_file) ) {
28
echo "File name is => ";
33
print("File is not created");
35
unlink($created_file);
38
unlink($dir_name."/tempnam_variation6.tmp");
41
echo "\n*** Done ***\n";
44
*** Test tempnam() function: by passing an existing filename as prefix ***
46
File name is => %stempnam_variation6%etempnam_variation6.tmp%s
48
File name is => %stempnam_variation6%etempnam_variation6.tmp%s
50
File name is => %stempnam_variation6%etempnam_variation6.tmp%s