2 /* Prototype: string realpath ( string $path );
3 Description: Returns canonicalized absolute pathname
6 echo "\n*** Testing basic functions of realpath() with files ***\n";
8 /* creating directories and files */
9 $file_path = dirname(__FILE__
);
10 mkdir("$file_path/realpath_basic/home/test/", 0777, true);
12 $file_handle1 = fopen("$file_path/realpath_basic/home/test/realpath_basic.tmp", "w");
13 $file_handle2 = fopen("$file_path/realpath_basic/home/realpath_basic.tmp", "w");
14 $file_handle3 = fopen("$file_path/realpath_basic/realpath_basic.tmp", "w");
15 fclose($file_handle1);
16 fclose($file_handle2);
17 fclose($file_handle3);
19 echo "\n*** Testing realpath() on filenames ***\n";
21 /* filenames resulting in valid paths */
22 "./realpath_basic/home/realpath_basic.tmp",
23 "./realpath_basic/realpath_basic.tmp",
24 "./realpath_basic//home/test//../test/./realpath_basic.tmp",
25 "./realpath_basic/home//../././realpath_basic.tmp",
27 /* filenames with invalid path */
28 // checking for binary safe
29 "./realpath_basicx000/home/realpath_basic.tmp",
31 ".///realpath_basic/home//..//././test//realpath_basic.tmp",
32 "./realpath_basic/home/../home/../test/..realpath_basic.tmp"
35 chdir("$file_path/..");
39 /* loop through $files to read the filepath of $file in the above array */
40 foreach($filenames as $file) {
41 echo "\n-- Iteration $counter --\n";
42 var_dump( realpath($file) );
48 $name_prefix = dirname(__FILE__
)."/realpath_basic";
49 unlink("$name_prefix/home/test/realpath_basic.tmp");
50 unlink("$name_prefix/home/realpath_basic.tmp");
51 unlink("$name_prefix/realpath_basic.tmp");
52 rmdir("$name_prefix/home/test/");
53 rmdir("$name_prefix/home/");
54 rmdir("$name_prefix/");