Annotation of embedaddon/php/ext/standard/tests/file/tempnam_variation5.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test tempnam() function: usage variations - existing file
3: --SKIPIF--
4: <?php
5: if(substr(PHP_OS, 0, 3) == "WIN")
6: die("skip Do not run on Windows");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype: string tempnam ( string $dir, string $prefix );
11: Description: Create file with unique file name.
12: */
13:
14: /* Passing an existing file as $prefix for tempnam() fn */
15:
16: $file_path = dirname(__FILE__);
17:
18: echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
1.1.1.2 ! misho 19: $dir_name = $file_path."/tempnam_variation5";
1.1 misho 20: mkdir($dir_name);
1.1.1.2 ! misho 21: $h = fopen($dir_name."/tempnam_variation5.tmp", "w");
1.1 misho 22:
23: for($i=1; $i<=3; $i++) {
24: echo "-- Iteration $i --\n";
1.1.1.2 ! misho 25: $created_file = tempnam("$dir_name", "tempnam_variation5.tmp");
1.1 misho 26:
27: if( file_exists($created_file) ) {
28: echo "File name is => ";
29: print($created_file);
30: echo "\n";
31: }
32: else
33: print("File is not created");
34:
35: unlink($created_file);
36: }
37: fclose($h);
1.1.1.2 ! misho 38: unlink($dir_name."/tempnam_variation5.tmp");
1.1 misho 39: rmdir($dir_name);
40:
41: echo "\n*** Done ***\n";
42: ?>
43: --EXPECTF--
44: *** Test tempnam() function: by passing an existing filename as prefix ***
45: -- Iteration 1 --
1.1.1.2 ! misho 46: File name is => %stempnam_variation5%etempnam_variation5.tmp%s
1.1 misho 47: -- Iteration 2 --
1.1.1.2 ! misho 48: File name is => %stempnam_variation5%etempnam_variation5.tmp%s
1.1 misho 49: -- Iteration 3 --
1.1.1.2 ! misho 50: File name is => %stempnam_variation5%etempnam_variation5.tmp%s
1.1 misho 51:
52: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>