Directories Apart from manipulating individual files, PHP provides
Directories Apart from manipulating individual files, PHP provides functions for handling directories. PHP’s directory APIs can be used to create and delete new directories, and to read the contents of a directory: int chdir(string directory) The current directory of the PHP process can be set by the chdir()function. If you are accessing a number of files in a directory, then you may want to change the current directory to point to the directory containing these files: string getcwd() You can get the current directory using the getcwd() function. It returns the current working directory: int opendir(string path) For reading the contents of a directory, you first need to open the directory. The opendir()function opens the directory specified by path. It returns a directory handle on success, which can be used to refer to the open directory in subsequent function calls: string readdir(int dir) Once you have opened the directory, you can read its contents with the readir()function. The readir()function returns the name of the next entry in the directory. If there are no more entries in the directory, or if the directory handle is invalid, then the function returns false. Apart from files and sub-folders, each directory contains two special entries “.” and “..”. The “.” entry refers to the current directory and “..” refers to the parent directory. The current directory can be opened by opening “.”: $dir = opendir(”.”) Once you have read the contents of the directory, you should close it and free all the resources associated with it: void closedir($dir) The following code deletes files which were not accessed in the last ten days from the temp/ directory:
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services