PHPDirectory function details. Predefined constant: DIRECTORY_SEPARATOR (string): directory separator PATH_SEPARATOR (string): path separator boolchdir (string $ directory)-Change the directory copy code as follows:
DIRECTORY_SEPARATOR (string): directory separator
PATH_SEPARATOR (string): path separator
Bool chdir (string $ directory)-Change directory
The code is as follows:
Echo getcwd (). "\ n ";
Chdir ('public _ html ');
Echo getcwd (). "\ n ";
Bool chroot (string $ directory)-change the root directory only when the system supports and runs on CLI, CGI, or SAPI version.
Dir: dir (string $ directory)-directory class. There are three methods available: read, rewind (pointing the position pointer inside the file to the beginning of a data stream again) and close
The code is as follows:
$ D = dir ("E:/work/html ");
Foreach ($ d as $ k => $ v ){
Echo $ k. '->'. $ v .'
';
}
While (false! ==( $ Entry = $ d-> read ())){
Echo $ entry ."
";
}
$ D-> close ();
Void closedir (resource $ dir_handle)-close directory handle
The code is as follows:
$ Dir = "/etc/php5 /";
If (is_dir ($ dir )){
If ($ dh = opendir ($ dir )){
$ Directory = readdir ($ dh );
Closedir ($ dh );
}
}
String getcwd (void)-get the current working directory
Resource opendir (string $ path [, resource $ context])-open the directory handle
String readdir (resource $ dir_handle)-read entries from the directory handle
The code is as follows:
If ($ handle = opendir ('/path/to/Files ')){
Echo "Directory handle: $ handle \ n ";
Echo "Files: \ n ";
While (false! ==( $ File = readdir ($ handle ))){
Echo "$ file \ n ";
}
Closedir ($ handle );
}
Void rewinddir (resource $ dir_handle)-reset the directory stream specified by dir_handle to the beginning of the Directory
Array scandir (string $ directory [, int $ sorting_order [, resource $ context])-List files and directories in a specified path
The code is as follows:
$ Dir = '/tmp ';
$ Files1 = scandir ($ dir );
$ Files2 = scandir ($ dir, 1 );
Print_r ($ files1 );
Print_r ($ files2 );
Export DIRECTORY_SEPARATOR (string): directory separator PATH_SEPARATOR (string): path separator bool chdir (string $ directory)-Change the directory code as follows...