Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

string readdir(integer directory_handle)y


The readdir function returns the name of the next file from a directory handle created by
opendir, or FALSE when no entries remain. You can place readdir in the conditional
expression of a while loop to get every entry in a directory. Keep in mind that. and .. are
always present and will be returned. See closedir for an example of use.


integer readfile(string filename)


The file given is read and sent directly to the browser by the readfile function, and the
number of bytes read is returned. If an error occurs, false is returned. If the filename
begins with http:// or ftp://, the file will be fetched using HTTP or FTP,
respectively. Otherwise the file is opened in the local filesystem. If you need to send a
compressed file to the browser, use readgzfile. If you'd rather read a file into a
variable, use the file function.


<?
print("Here is some data BR>\n");
readfile("data.txt");
?>


string readlink(string filename)


The readlink function returns the path to which a symbolic link points. It returns false
on error. Another function that gets information about a link is linkinfo.


<?
print(readlink("data.txt"));
?>


boolean rename(string old_name, string new_name)


The rename function changes the name of a file specified by the old_name argument to
the name specified in the new_name argument. The new and old names may contain
complete paths, which allows you to use rename to move files.


<?
//move data.txt from local directory
//to the temp directory
rename("./data.txt", "/tmp/data.dat");
?>

Free download pdf