import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / tempnam_variation3.php
blob1af07d6b7216f36b752321d10d5d13a801b94f62
1 <?php
2 /* Prototype: string tempnam ( string $dir, string $prefix );
3 Description: Create file with unique file name.
4 */
6 /* Passing invalid/non-existing args for $prefix */
8 echo "*** Testing tempnam() with obscure prefixes ***\n";
9 $file_path = dirname(__FILE__)."/tempnamVar3";
10 mkdir($file_path);
12 /* An array of prefixes */
13 $names_arr = array(
14 /* Invalid args */
15 -1,
16 TRUE,
17 FALSE,
18 NULL,
19 "",
20 " ",
21 "\0",
22 array(),
24 /* prefix with path separator of a non existing directory*/
25 "/no/such/file/dir",
26 "php/php"
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 => ";
37 print($file_name);
38 echo "\n";
40 echo "File permissions are => ";
41 printf("%o", fileperms($file_name) );
42 echo "\n";
44 echo "File created in => ";
45 $file_dir = dirname($file_name);
47 if ($file_dir == sys_get_temp_dir()) {
48 echo "temp dir\n";
50 else if ($file_dir == $file_path) {
51 echo "directory specified\n";
53 else {
54 echo "unknown location\n";
58 else {
59 echo "-- File is not created --\n";
62 unlink($file_name);
65 rmdir($file_path);
66 echo "\n*** Done ***\n";