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$level1_one_dir_name = "level1_one";
18$level1_one_dir_path = "$base_dir_path/$level1_one_dir_name";
19
20$level1_two_dir_name = "level1_two";
21$level1_two_dir_path = "$base_dir_path/$level1_one_dir_name/$level1_two_dir_name";
22
23// create directories
24mkdir($level1_one_dir_path);
25mkdir($level1_two_dir_path);
26
27echo "\n-- Testing chdir() with absolute path: --\n";
28chdir($base_dir_path);
29var_dump(chdir($level1_one_dir_path));
30var_dump(getcwd());
31
32echo "\n-- Testing chdir() with relative paths: --\n";
33var_dump(chdir($level1_two_dir_name));
34var_dump(getcwd());
35?>
36===DONE===
37--CLEAN--
38<?php
39$file_path = dirname(__FILE__);
40rmdir("$file_path/level1_one/level1_two");
41rmdir("$file_path/level1_one");
42?>
43--EXPECTF--
44*** Testing chdir() : basic functionality ***
45
46-- Testing chdir() with absolute path: --
47bool(true)
48string(%d) "%slevel1_one"
49
50-- Testing chdir() with relative paths: --
51bool(true)
52string(%d) "%slevel1_one%elevel1_two"
53===DONE===
54