• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16. PHP > File Functions

16.18. File Functions

The following functions manipulate the local filesystem in some manner:


string basename(string path)

Return the filename component of the path


int chgrp(string filename, mixed group)

Change the file group


int chmod(string filename, int mode)

Change the file mode


int chown(string filename, mixed user)

Change the file owner


void clearstatcache(void)

Clear the file stat cache


int copy(string source_file, string destination_file)

Copy a file


string dirname(string path)

Return the directory name component of the path


int fclose(int fp)

Close an open file pointer


int feof(int fp)

Test for end-of-file on a file pointer


string fgetc(int fp)

Get a character from the file pointer


string fgets(int fp, int length)

Get a line from the file pointer


string fgetss(int fp, int length)

Get a line from the file pointer and strip HTML tags


array file(string filename)

Read an entire file into an array


int file_exists(string filename)

Check whether a file exists or not


int fileatime(string filename)

Get the last access time for a file


int filectime(string filename)

Get the last inode status change for a file


int filegroup(string filename)

Return the group ID of the file


int fileinode(string filename)

Return the inode number of the file


int filemtime(string filename)

Return the time the file was last modified


int fileowner(string filename)

Return the user ID of the owner of the file


int fileperms(string filename)

Return the file permission bits of the file


int filesize(string filename)

Return the size of the file


string filetype(string filename)

Return the type of the file (fifo, char, block, link, file, or unknown)


int fopen(string filename, string mode)

Open a file or a URL and return a file pointer


int fpassthru(int fp)

Output all remaining data from a file pointer


int fputs(int fp, string str [, int length])

Write to a file pointer


int fread(int fp, int length)

Binary-safe file read


int fseek(int fp, int offset)

Seek on a file pointer


int ftell(int fp)

Get the file pointer's read/write position


int fwrite(int fp, string str [, int length])

Binary-safe file write


array get_meta_tags(string filename [, int use_include_path])

Extract all meta tag content attributes from a file and return an array


bool is_dir(string pathname)

Return true if the pathname is a directory


bool is_executable(string filename)

Return true if filename is executable


bool is_file(string filename)

Return true if filename is a regular file


bool is_link(string filename)

Return true if filename is a symbolic link


bool is_readable(string filename)

Return true if filename exists and is readable


bool is_writable(string filename)

Return true if filename exists and is writable


int link(string target, string link)

Create a hard link


int linkinfo(string filename)

Return the st_dev field of the Unix C stat structure describing the link


array lstat(string filename)

Return an array that contains information about the file; follows symbolic links


int mkdir(string pathname, int mode)

Create a directory


int pclose(int fp)

Close a file pointer opened by popen()


int popen(string command, string mode)

Execute a command and open either a read or a write pipe to it


int readfile(string filename)

Output a file or a URL


int readlink(string filename)

Return the target of a symbolic link


int rename(string old_name, string new_name)

Rename a file


int rewind(int fp)

Rewind the position of a file pointer


int rmdir(string dirname)

Remove a directory


array stat(string filename)

Return an array that contains information about the file; does not follow symbolic links


int symlink(string target, string link)

Create a symbolic link


string tempnam(string dir, string prefix)

Create a unique filename in a directory


int touch(string filename[, int time])

Create an empty file or set modification time of an existing one


int umask(int mask)

Changes the current umask


int unlink(string filename)

Delete a file


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint