You are on page 1of 5

4/19/2016

PHP5FilesystemFunctions

Thebehaviorofthefilesystemfunctionsisaffectedbysettingsinphp.ini.
Filesystemconfigurationoptions:

Name

Default

Description

Changeable

allow_url_fopen

"1"

Allowsfopen()type
functionstoworkwithURLs
(availablesincePHP4.0.4)

PHP_INI_SYSTEM

user_agent

NULL

Definestheuseragentfor
PHPtosend(available
sincePHP4.3)

PHP_INI_ALL

"60"

Setsthedefaulttimeout,in
seconds,forsocketbased
streams(availablesince
PHP4.3)

PHP_INI_ALL

from

""

DefinestheanonymousFTP
password(youremail
address)

PHP_INI_ALL

auto_detect_line_endings

"0"

Whensetto"1",PHPwill
examinethedatareadby
fgets()andfile()toseeifit
isusingUnix,MSDosor
Maclineendingcharacters
(availablesincePHP4.3)

PHP_INI_ALL

default_socket_timeout
PHP

PHP 5 Filesystem Functions


Function

Description

basename()

Returnsthefilenamecomponentofapath

chgrp()

Changesthefilegroup

chmod()

Changesthefilemode

chown()

Changesthefileowner

http://www.w3schools.com/php/php_ref_filesystem.asp

2/10

4/19/2016

PHP5FilesystemFunctions

clearstatcache()

Clearsthefilestatuscache

copy()

Copiesafile

delete()

Seeunlink()orunset()

dirname()

Returnsthedirectorynamecomponentofapath

disk_free_space()

Returnsthefreespaceofadirectory

disk_total_space()

Returnsthetotalsizeofadirectory

diskfreespace()

Aliasofdisk_free_space()

fclose()

Closesanopenfile

feof()

Testsforendoffileonanopenfile

fflush()

Flushesbufferedoutputtoanopenfile

fgetc()

Returnsacharacterfromanopenfile

fgetcsv()

Parsesalinefromanopenfile,checkingforCSVfields

fgets()

Returnsalinefromanopenfile

fgetss()

Returnsaline,withHTMLandPHPtagsremoved,froman
openfile

file()

Readsafileintoanarray

file_exists()

Checkswhetherornotafileordirectoryexists

file_get_contents()

Readsafileintoastring

file_put_contents()

Writesastringtoafile

fileatime()

Returnsthelastaccesstimeofafile

filectime()

Returnsthelastchangetimeofafile

filegroup()

ReturnsthegroupIDofafile

fileinode()

Returnstheinodenumberofafile

filemtime()

Returnsthelastmodificationtimeofafile

http://www.w3schools.com/php/php_ref_filesystem.asp

3/10

4/19/2016

PHP5FilesystemFunctions

fileowner()

ReturnstheuserID(owner)ofafile

fileperms()

Returnsthepermissionsofafile

filesize()

Returnsthefilesize

filetype()

Returnsthefiletype

flock()

Locksorreleasesafile

fnmatch()

Matchesafilenameorstringagainstaspecifiedpattern

fopen()

OpensafileorURL

fpassthru()

Readsfromanopenfile,untilEOF,andwritestheresultto
theoutputbuffer

fputcsv()

FormatsalineasCSVandwritesittoanopenfile

fputs()

Aliasoffwrite()

fread()

Readsfromanopenfile

fscanf()

Parsesinputfromanopenfileaccordingtoaspecified
format

fseek()

Seeksinanopenfile

fstat()

Returnsinformationaboutanopenfile

ftell()

Returnsthecurrentpositioninanopenfile

ftruncate()

Truncatesanopenfiletoaspecifiedlength

fwrite()

Writestoanopenfile

glob()

Returnsanarrayoffilenames/directoriesmatchinga
specifiedpattern

is_dir()

Checkswhetherafileisadirectory

is_executable()

Checkswhetherafileisexecutable

is_file()

Checkswhetherafileisaregularfile

is_link()

Checkswhetherafileisalink

http://www.w3schools.com/php/php_ref_filesystem.asp

4/10

4/19/2016

PHP5FilesystemFunctions

is_readable()

Checkswhetherafileisreadable

is_uploaded_file()

CheckswhetherafilewasuploadedviaHTTPPOST

is_writable()

Checkswhetherafileiswriteable

is_writeable()

Aliasofis_writable()

lchgrp()

Changesgroupownershipofsymlink

lchown()

Changesuserownershipofsymlink

link()

Createsahardlink

linkinfo()

Returnsinformationaboutahardlink

lstat()

Returnsinformationaboutafileorsymboliclink

mkdir()

Createsadirectory

move_uploaded_file()

Movesanuploadedfiletoanewlocation

parse_ini_file()

Parsesaconfigurationfile

parse_ini_string()

Parsesaconfigurationstring

pathinfo()

Returnsinformationaboutafilepath

pclose()

Closesapipeopenedbypopen()

popen()

Opensapipe

readfile()

Readsafileandwritesittotheoutputbuffer

readlink()

Returnsthetargetofasymboliclink

realpath()

Returnstheabsolutepathname

realpath_cache_get()

Returnsrealpathcacheentries

realpath_cache_size()

Returnsrealpathcachesize

rename()

Renamesafileordirectory

rewind()

Rewindsafilepointer

http://www.w3schools.com/php/php_ref_filesystem.asp

5/10

4/19/2016

PHP5FilesystemFunctions

rmdir()

Removesanemptydirectory

set_file_buffer()

Setsthebuffersizeofanopenfile

stat()

Returnsinformationaboutafile

symlink()

Createsasymboliclink

tempnam()

Createsauniquetemporaryfile

tmpfile()

Createsauniquetemporaryfile

touch()

Setsaccessandmodificationtimeofafile

umask()

Changesfilepermissionsforfiles

unlink()

Deletesafile

Previous

http://www.w3schools.com/php/php_ref_filesystem.asp

NextChapter

6/10

You might also like