2 /* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
3 Description: Renames a file or directory
6 require dirname(__FILE__
).'/file.inc';
8 /* creating directory */
9 $file_path = dirname(__FILE__
);
11 // rename dirs across directories
12 echo "\n*** Testing rename() : renaming directory across directories ***\n";
14 /* Testing simple directory tree */
15 "$file_path/rename_variation/",
17 /* Testing a dir with trailing slash */
18 "$file_path/rename_variation/",
20 /* Testing dir with double trailing slashes */
21 "$file_path//rename_variation//",
24 $dest_dir = "$file_path/rename_variation_dir";
26 // create the $dest_dir
31 /* loop through each $src_dirs and rename it to $dest_dir */
32 foreach($src_dirs as $src_dir) {
33 echo "-- Iteration $counter --\n";
36 mkdir("$file_path/rename_variation/");
37 // rename the src dir to a new dir in dest dir
38 var_dump( rename($src_dir, $dest_dir."/new_dir") );
39 // ensure that dir was renamed
40 var_dump( file_exists($src_dir) ); // expecting false
41 var_dump( file_exists($dest_dir."/new_dir") ); // expecting true
44 rmdir($dest_dir."/new_dir");
50 $file_path = dirname(__FILE__
);
51 unlink($file_path."/rename_variation_link.tmp");
52 unlink($file_path."/rename_variation.tmp");
53 rmdir($file_path."/rename_variation_dir");