<<

. 104
( 132 .)



>>

program
output [, int return_value]])

int Executes an external
system(string command
program and displays
[, int return_value])
output
void Executes an external
passthru(string command
program and displays raw
[, int return_value])
output
string Escapes shell
escapeshellcmd(string command)
meta-characters
string Quotes and escapes an
escapeshellarg(string arg)
argument for use in a shell
command that has been
opened via popen()
Appendix F: PHP Function Reference 623


TABLE F-8 FUNCTIONS FOR WORKING WITH FILES

Function Return Value Action

bool Portable file locking
flock(resource fp, int operation
[, int wouldblock])

array Extracts all metatag
get_meta_tags(string filename
content attributes from a
[, bool use_include_path])
file and returns an array
array Reads the entire file into
file(string filename
an array
[, bool use_include_path])

string Creates a unique file name
tempnam(string dir,
in a directory
string prefix)

resource Creates a temporary file
tmpfile(void)
that will be deleted
automatically after use
resource Opens a file or a URL and
fopen(string filename, string
returns a file pointer
mode [, bool use_include_path])

bool Closes an open file pointer
fclose(resource fp)

resource Executes a command and
popen(string command,
opens either a read or a
string mode)
write pipe to it
int Closes a file pointer
pclose(resource fp)
opened by popen()
bool Tests for end-of-file on a
feof(resource fp)
file pointer
bool Sets blocking/non-blocking
socket_set_blocking(resource
mode on a socket
socket, int mode)

bool Sets blocking/non-blocking
set_socket_blocking(resource
mode on a socket
socket, int mode)

bool Sets timeout on socket
socket_set_timeout(int
read to seconds plus
socket_descriptor, int seconds,
int microseconds) microseconds

array Returns an array describing
socket_get_status(resource
socket status
socket_descriptor)

Continued
624 Part V: Appendixes


TABLE F-8 FUNCTIONS FOR WORKING WITH FILES (Continued)

Function Return Value Action

string Gets a line from the file
fgets(resource fp[, int length])
pointer
string Gets a character from the
fgetc(resource fp)
file pointer
string Gets a line from the file
fgetss(resource fp, int length
pointer and strips HTML
[, string allowable_tags])
tags
mixed Implements a mostly-
fscanf(string str, string
ANSI-compatible
format [, string ...])
fscanf()

int Binary-safe file write
fwrite(resource fp, string str
[, int length])

bool Flushes output
fflush(resource fp)

int Sets file write buffer
set_file_buffer(resource
fp, int buffer)

bool Rewinds the position of a
rewind(resource fp)
file pointer
int Gets the file pointer™s
ftell(resource fp)
read/write position
int Seeks on a file pointer
fseek(resource fp, int offset
[, int whence])

bool Creates a directory
mkdir(string pathname
[, int mode])

bool Removes a directory
rmdir(string dirname)

int Outputs a file or a URL
readfile(string filename
[, int use_include_path])

int Returns or changes the
umask([int mask])
umask

int Outputs all remaining data
fpassthru(resource fp)
from a file pointer
Appendix F: PHP Function Reference 625



Function Return Value Action

bool Renames a file
rename(string old_name,
string new_name)

bool Deletes a file
unlink(string filename)

int Truncates file to length
ftruncate(resource fp, int size)
size

int Stat() on a file handle
fstat(resource fp)

bool Copies a file
copy(string source_file,
string destination_file)

string Binary-safe file read
fread(resource fp, int length)

array Gets a line from the file
fgetcsv(resource fp, int length
pointer and parses it for
[, string delimiter])
CSV fields
string Returns the resolved path
realpath(string path)




TABLE F-9 FILE STATUS FUNCTIONS

Function Return Value Action

float Gets total disk space for
disk_total_space(string path)
the file system that path
is on
float Gets free disk space for
disk_free_space(string path)
the file system that path
is on
bool Changes the file group
chgrp(string filename, mixed group)

bool Changes the file owner
chown (string filename, mixed user)

bool Changes the file mode
chmod(string filename, int mode)

bool Sets the modification
touch(string filename [, int time
time for the file
[, int atime]])

void Clears the file™s stat cache
clearstatcache(void)

Continued
626 Part V: Appendixes


TABLE F-9 FILE STATUS FUNCTIONS (Continued)

Function Return Value Action

int Gets file permissions
fileperms(string filename)

int Gets the file inode
fileinode(string filename)

int Gets the file size
filesize(string filename)

int Gets the file owner
fileowner(string filename)

int Gets the file group
filegroup(string filename)

int Gets the last access time
fileatime(string filename)
for the file
int Gets the last modification
filemtime(string filename)
time for the file
int Gets the inode-
filectime(string filename)
modification time for
the file
string Gets the file type
filetype(string filename)

int Returns true if the file
is_writable(string filename)
can be written
int Returns true if the file
is_readable(string filename)
can be read
int Returns true if the file is
is_executable(string filename)
executable
int Returns true if the file is
is_file(string filename)
a regular file

<<

. 104
( 132 .)



>>