1--TEST--
2Test chdir() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : bool chdir(string $directory)
6 * Description: Change the current directory
7 * Source code: ext/standard/dir.c
8 */
9
10/*
11 * Test basic functionality of chdir() with absolute and relative paths
12 */
13
14echo "*** Testing chdir() : basic functionality ***\n";
15$base_dir_path = dirname(__FILE__);
16
17$level_one_dir_name = "level_one";
18$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
19
20$level_two_dir_name = "level_two";
21$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
22
23// create directories
24mkdir($level_one_dir_path);
25mkdir($level_two_dir_path);
26
27echo "\n-- Testing chdir() with absolute path: --\n";
28chdir($base_dir_path);
29var_dump(chdir($level_one_dir_path));
30var_dump(getcwd());
31
32echo "\n-- Testing chdir() with relative paths: --\n";
33var_dump(chdir($level_two_dir_name));
34var_dump(getcwd());
35?>
36===DONE===
37--CLEAN--
38<?php
39$file_path = dirname(__FILE__);
40rmdir("$file_path/level_one/level_two");
41rmdir("$file_path/level_one");
42?>
43--EXPECTF--
44*** Testing chdir() : basic functionality ***
45
46-- Testing chdir() with absolute path: --
47bool(true)
48string(%d) "%slevel_one"
49
50-- Testing chdir() with relative paths: --
51bool(true)
52string(%d) "%slevel_one%elevel_two"
53===DONE===
54