PHP Developer's Dictionary- P8:PHP is an open source, server-side, HTML-embedded scripting language used to create dynamically generated Web pages. With an easy-to-use syntax and a large, extensible library of modules, PHP brings together the best of Perl, C++, and other languages. | PHP Developer s Dictionary dirname . if is_dir dirname print dirname. is a directory else print dirname. is not a directory body html With the object-oriented look and feel of some of the functions in PHP reading a directory is as simple as using the directory object and the read method. The following example illustrates the use of the dir function and the associated read and close methods HEAD TITLE Reading a Directory TITLE HEAD BODY dirname . dh dir dirname while filename dh- read print filename br dh- close BODY HTML These simple examples illustrate the use of some of the directory functions in PHP. Because of the nature of the filesystem some of the functions that operate on directories also perform a similar operation on files. The following section discusses some of these functions. Filesystem Functions The method of working with directory handles described earlier holds true for filesystem functions. Some functions use file handles and others do not. Some of the functions that do not require file handles are is_readable is_writeable and filesize . Examples of how to use these functions are described in the following code snippets. The following code snippet checks the file named and returns a string indicating whether the file is readable if is_readable print The file IS readable else print The file IS NOT readable IT-SC book 35 PHP Developer s Dictionary The following snippet of code is similar to the preceding code except that it checks whether is writeable and returns the appropriate string if is_writeable print The file else print The file IS writeable IS NOT writeable You can also return other information about a file. For instance our fictional file has certain properties that can be displayed. These properties include the last access time the last modified time the last changed time and the size of the file. The following sample code illustrates how to return the information .