2 /* Prototype: string tempnam ( string $dir, string $prefix );
3 Description: Create file with unique file name.
6 /* Passing invalid/non-existing args for $prefix */
8 echo "*** Testing tempnam() with obscure prefixes ***\n";
9 $file_path = dirname(__FILE__
)."/tempnamVar3";
12 /* An array of prefixes */
24 /* prefix with path separator of a non existing directory*/
30 for( $i=0; $i<count($names_arr); $i++
) {
31 echo "-- Iteration $i --\n";
32 $file_name = tempnam("$file_path", $names_arr[$i]);
34 /* creating the files in existing dir */
35 if( file_exists($file_name) ) {
36 echo "File name is => ";
40 echo "File permissions are => ";
41 printf("%o", fileperms($file_name) );
44 echo "File created in => ";
45 $file_dir = dirname($file_name);
47 if ($file_dir == sys_get_temp_dir()) {
50 else if ($file_dir == $file_path) {
51 echo "directory specified\n";
54 echo "unknown location\n";
59 echo "-- File is not created --\n";
66 echo "\n*** Done ***\n";