HOW THE QUIZ WORKS:
Clicking the ‘randomize’ button situated above the reference table generates a new table whereby the function descriptions, function syntaxes, and function return values are randomized. The quiz involves matching the function descriptions, function syntaxes, and function return values to the correct function name. Information relating to the randomization of table cells will be displayed for three seconds, before disappearing.
On a desktop computer, table elements are selected by left-clicking the desired table cell and holding the left click in the mouse down position for one second before releasing the left click. The text inside the table cell will turn red to indicate that the one-second mouse left-click has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second left mouse-click process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second left mouse-click process on the original table cell.
To select a table element on a touchscreen device (mobile, tablet), simply touch the desired table cell and maintain the touch for one second before removing your finger from the screen. The text inside the table cell will turn red to indicate that the one-second touch has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second touch process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second touch process on the original table cell.
Normal touchscreen scrolling behaviour is exhibited by the cells with a light green background; cells without a light green background will not respond to normal touchscreen scrolling. The table is positioned in such a way that the user can also initiate touchscreen scrolling by swiping to the right or left of the table.
When a row consists of the correct function name, function description, function syntax, and function return value, the background colour of the row will change from ‘transparent’ to ‘khaki’; this provides visual feedback that the row is complete.
Once the entire table is complete, a paragraph of feedback will congratulate the user and provide the following information: date and time of quiz commencement; date and time of quiz completion; and the length of time it took the user to complete the quiz.
VIEWPORT OPTIONS:



PURPOSE:
This webpage serves two purposes:
- It provides a reference table for the PHP filesystem functions, with information extracted and condensed from w3schools.com, phptutorial.info and php.net.
- It enables users to complete a quiz related to the PHP filesystem functions.
USAGE:
For each filesystem function there are four table cells of information: the function name; the function description; the function syntax; and the function return value. There are three layouts available – ‘mobile‘, ‘tablet‘, and ‘desktop‘.
Click the relevant button below to display the PHP filesystem functions reference table, sized appropriately for the desired viewport. A ‘RANDOMIZE‘ button appears above the reference table once the viewport is selected; clicking this button facilitates the commencement of a quiz.
Click the ‘RANDOMIZE‘ button to randomize the functional descriptions, the functional syntaxes, and the functional return information.
FUNCTION NAME | FUNCTION DESCRIPTION | FUNCTION SYNTAX | FUNCTION RETURN VALUE |
---|---|---|---|
basename()
[Returns trailing name component of path] |
This function returns the trailing name component [‘base name’] of the path to a file or directory specified in path_string. basename() is not aware of the actual filesystem, although it is locale-aware. |
basename(path_string, suffix [optional parameter – if the name ends in ‘suffix’ this will also be cut off]);
[path_string: on Windows systems, both forward slashes and backslashes can be used as directory separators; on other systems it is only the forward slash.] |
basename() : returns the base name of the given path_string. |
chgrp()
[Changes file group] |
This function attempts to change the group of the file filename to group. The superuser may change the group of a file arbitrarily; other users may change the group of a file to any group of which that user is a member. | chgrp(filename, group); |
chgrp() : returns TRUE on success, FALSE on failure. |
chmod()
[Changes file mode] |
Attempts to change the mode of the file specified in filename to that given in mode. | chmod(filename, mode);
[The mode parameter must be prefixed by a 0. Execute [1], write [2], and read [4] rights can be specified for the owner, the user group of the owner, and for everybody else – in that order.] |
chmod() : returns TRUE on success, or FALSE on failure. |
chown()
[Changes file owner] |
This function attempts to change the owner of filename to user. Only the superuser is permitted to change the owner of a file. | chown(filename, user |
chown() : returns TRUE on success; FALSE on failure. |
clearstatcache()
[Clears file status cache] |
PHP caches the information returned by certain functions in order to provide speedier performance. The functions for which the information is cached are: stat() , lstat() , file_exists() , is_writable() , is_readable() , is_executable() , is_file() , is_dir() , is_link() , filectime() , fileatime() , filemtime() , fileinode() , filegroup() , fileowner() , filesize() , filetype() and fileperms() . If you are performing multiple operations on the same filename and require the information to not be cached, use clearstatcache() . |
clearstatcache(clear_realpath_cache [optional parameter, default value of FALSE], filename [only used if clear_realpath_cache() is TRUE]); |
clearstatcache() : no value is returned. |
copy()
[copy – Copies file] |
This function makes a copy of the file source to destination. In order to move a file, use the rename() function. |
copy(source, destination, context [optional parameter]);
[source is a string specifying the path to the source file. destination specifies the destination path. If this destination string is a URL, the copy operation may fail if the wrapper does not support the overwriting of existing files. If the destination file already exists, it will be overwritten.] |
copy() : returns TRUE on success; FALSE on failure. |
dirname()
[dirname – Returns a parent directory’s path] |
When passed a string containing the path of a file or directory, this function will return the parent directory’s path [‘name’] that is levels up from the current directory. This function is locale-aware, so the matching locale must be set with setlocale() for it to see the correct directory name with multibyte character paths. |
dirname(path, levels [optional parameter]);
[levels specifies the number of parent directories to go up. This must be an integer greater than 0; the default value is 1.] |
dirname() : returns the path of a parent directory. If there are no slashes in path, a dot (.) is returned – indicating the current directory. Otherwise, the returned string is path with any trailing /component removed. |
disk_free_space()
[disk_free_space – Returns available space on filesystem or disk partition] |
This function – when given a string containing a directory – will return the number of bytes available [‘free space’] on the corresponding filesystem or disk partition. | disk_free_space(directory_string);
[If given a file name rather than a directory, the behaviour of the function is unspecified and may differ between operating systems and PHP versions.] |
disk_free_space() : returns the number of available bytes as a float on success; FALSE on failure. |
disk_total_space()
[disk_total_space – Returns the total size of a filesystem or disk partition] |
This function returns the total number of bytes [‘total space’] on the filesystem or disk partition specified by directory_string. | disk_total_space(directory_string); |
disk_total_space() : returns the total number of bytes as a float on success; FALSE on failure. |
fclose()
[fclose – Closes an open file pointer] |
This function closes the file pointed to by resource_handle. | fclose(resource_handle);
[resource_handle must be valid, and must point to a file successfully opened by |
fclose() : returns TRUE on success; FALSE on failure. |
feof()
[feof – Tests for end of file on a file pointer] |
Tests resource_handle for end-of-file. | feof(resource_handle); |
feof() : returns TRUE if resource_handle is at end-of-file or an error occurs (including socket timeout); otherwise FALSE. |
fflush()
[fflush – Flushes the output to a file] |
This function forces a write of [‘flushes’] all buffered output to the resource pointed to by file_handle. | fflush(file_handle);
[file_handle must be valid, and must point to a file successfully opened by |
fflush() : returns TRUE on success; FALSE on failure. |
fgetc()
[fgetc – Gets character from file pointer] |
This function gets a character from file_pointer. Use the === operator to test the return value of this function. |
fgetc(file_pointer); |
fgetc() : returns a string containing a single character read from file_pointer on success; FALSE on end-of-file. |
fgetcsv()
[fgetcsv – Gets line from file pointer and parses for CSV fields] |
This locale-aware function parses the line it reads [‘gets’] from file_pointer for fields in CSV format and returns an array containing the fields read. | fgetcsv(file_pointer, length, delimiter, enclosure, escape);
[length is an optional parameter, with a default value of 0. Allowing for trailing line-end characters, length must be greater than the longest line (in characters) to be found in the CSV file; otherwise the line is split into chunks of length characters, unless the split would occur inside an enclosure. delimiter is an optional single-character parameter, with a default value of “,“. enclosure is an optional single-character parameter, with a default value of ‘“”‘. escape is an optional parameter, with a default value of “\\“.] |
fgetcsv() : returns an indexed array of the values read. A blank line in a CSV file will be returned as an array comprising a single null field, rather than being treated as an error. If an invalid file_pointer is specified, NULL is returned; for all other errors – including end-of-file – FALSE is returned. Enabling the auto_detect_line_endings run-time configuration option may help to resolve the issue of PHP not properly recognizing line endings when reading files either on or created by a Macintosh computer. |
fgets()
[fgets – Gets line from file pointer] |
This function gets a line from file_pointer. Reading ends when length-1 bytes have been read, or a newline (included in the return value) is reached, or an EOF is encountered. | fgets(file_pointer, length [optional parameter – specifies a length in bytes]);
[Until PHP 4.3.0, omitting length would result in the function defaulting to a length of 1024 bytes. It is more efficient to specify the maximum line length if the majority of lines in the file are larger than 8KB.] |
fgets() : returns a string of up to length-1 bytes read from the file pointed to by file_pointer. FALSE is returned if there is no more data to read in file_pointer, or if an error occurs. |
fgetss()
[fgetss – Gets line from file pointer and and strips HTML tags] |
This function gets a line from file_pointer and strips any NUL bytes, HTML and PHP tags from the text that it reads. Relying on this function is strongly discouraged, since it has been deprecated as of PHP 7.3.0. | fgetss(file_pointer, length [optional parameter], allowable_tags [optional parameter]);
[allowable_tags can be used to specify tags that should NOT be stripped.] |
fgetss() : returns a string of up to length-1 bytes read from the file pointed to by file_pointer, with all NUL bytes, HTML, and PHP code stripped. FALSE is returned if an error occurs. |
file_exists()
[file_exists – Checks whether a file or directory exists] |
This function checks whether the file or directory specified by filename exists. The results of this function are cached. | file_exists(filename);
[On Windows, use |
file_exists() : returns TRUE if the file or directory specified by filename exists; FALSE otherwise. FALSE is returned for files that are inaccessible owing to safe mode restrictions; these files can still be included if they are located in safe_mode_include_dir . An E_WARNING is emitted upon failure. |
file_get_contents()
[file_get_contents – Reads entire file into a string] |
This function returns [‘gets’] the contents of the file specified by filename as a string, starting at offset up to maxlen bytes. urlencode() is needed in instances where you’re opening a URI with special characters (such as spaces). |
file_get_contents(filename, use_include_path [optional parameter with a default value of FALSE], resource_context [optional parameter, skippable by NULL], offset [optional parameter with a default value of 0], maxlen [optional parameter]);
[offset specifies where reading starts on the original stream. |
file_get_contents() : returns the read data on success; FALSE on failure. An E_WARNING-level error is generated if filename cannot be found, maxlen is less than 0, or if seeking to the specified offset fails. |
file_put_contents()
[file_put_contents – Write data to a file] |
This function writes [‘puts’] data [‘contents’] to filename; identical to calling fopen() , fwrite() , and fclose() successively to write data to a file. The file will be created if filename does not exist. Unless the FILE_APPEND flag is set, the existing file will be overwritten. |
file_put_contents(filename, data, flags [optional parameter with a default value of 0], context [optional parameter]);
[data can be a string, array, or a stream resource. If a stream resource, the remaining buffer of data stream will be copied to the specified file. The value of flags can be any combination of the following flags, joined by the BINARY OR [|] operator: FILE_USE_INCLUDE_PATH; FILE_APPEND; LOCK_EX. context denotes a valid context resource created with |
file_put_contents() : returns the number of bytes that were written to the file; FALSE on failure. |
file()
[file – Reads entire file into an array] |
Whereas file_get_contents() reads a file into a string, this function reads an entire file into an array. |
file(filename, flags [optional parameter, default value of 0], context [optional parameter]);
[A URL can be used as filename if the |
file() : returns the file as an array; each element in the array corresponds to a line of the file, with the newline still attached [unless FILE_IGNORE_NEW_LINES] is set. FALSE is returned on failure. An E_WARNING-level error is emitted if the file does not exist. |
fileatime()
[fileatime – Gets last access time of file] |
This function returns the last access time of filename. The atime of a file changes whenever the data blocks of a file are being read; on filesystems with atime updates disabled, this function will be useless. | fileatime(filename); |
fileatime() : returns the time that filename was last accessed as a Unix timestamp on success; FALSE and an E_WARNING on failure. |
filectime()
[filectime – Gets inode change time of file] |
This function returns the inode change time of filename. A file is considered changed when its inode data is changed – videlicet, when the permissions, owner, group, or other metadata from the inode is updated. | filectime(filename); |
filectime() : returns the time the file was last changed as a Unix timestamp on success; FALSE and an E_WARNING on failure. |
filegroup()
[filegroup – Gets file group] |
This function returns the file group ID in numerical format. posix_getgrgid() can be used to resolve the returned value to a group name. |
filegroup(filename); |
filegroup() : returns the group ID of filename on success; FALSE and an E_WARNING on failure. |
fileinode()
[fileinode – Gets file inode] |
This function gets the file inode. | fileinode(filename); |
fileinode() : returns the inode number of the file on success; FALSE and an E_WARNING-level error on failure. |
filemtime()
[filemtime – Gets file modification time] |
This function returns the time that filename was last modified; modification occurs when the data blocks of a file are written to. | filemtime(filename); |
filemtime() : returns the time that filename was last modified as a Unix timestamp on success; FALSE and an E_WARNING-level error on failure. |
fileowner()
[fileowner – Gets file owner] |
This function returns the user ID of the file owner in numerical format; posix_getpwuid() can be used to resolve the returned value to a username. |
fileowner(filename); |
fileowner() : returns the user ID of the file owner on success; FALSE and an E_WARNING-level error on failure. |
fileperms()
[fileperms – Gets file permissions] |
This function returns the file permissions for the given filename. | fileperms(filename); |
fileperms() : returns the file permissions as a numeric mode. Lower bits of this mode are the same as that expected by chmod() , but the return value on most platforms will also include information on the type of file given in filename. An E_WARNING-level error is emitted on failure. |
filesize()
[filesize – Gets file size] |
This function returns the size of filename in bytes. | filesize(filename); |
filesize() : returns the size of the file in bytes on success; FALSE and an E_WARNING on failure. *** Since PHP’s integer type is signed and many platforms use 32-bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. *** |
filetype()
[filetype – Gets file type] |
This function returns the type of the given filename. | filetype(filename); |
filetype() : returns the type of the file – one of fifo, char, dir, block, link, file, socket, and unknown. Returns FALSE and an E_WARNING on failure; if the stat call fails or the file type is unknown, an E_NOTICE message is produced. |
flock()
[flock – Portable advisory file locking] |
PHP supports a portable way of locking complete files in an advisory way [i.e., all accessing programs have to use the same way of locking it or it will not work]. flock() facilitates the performance of a simple reader/writer model which can be used on virtually every platform. File unlocking has to be done manually, as of PHP version 5.3.2; prior to this, unlocking was done automatically when the resource_handle was closed. |
flock(resource_handle, operation, would_block [optional parameter]);
[operation can be one of the following values: LOCK_SH; LOCK_EX; LOCK_UN; or LOCK_NB (used as a bitmask to one of the three aforementioned values if you don’t want |
flock() : returns TRUE on success; FALSE on failure. Can only be used on file pointers returned by fopen() for local files, or file pointers pointing to userspace streams that implement the streamWrapper::stream_lock() method. |
fnmatch()
[fnmatch – Match filename against a pattern] |
This function tests whether the passed string would match the given shell wildcard pattern. This function can be used for regular strings but it is especially useful for testing filenames. | fnmatch(pattern, string, flags [optional parameter]);
[The optional flags parameter can be any of the following values, joined by the binary OR operator (|): FNM_NOESCAPE; FNM_PATHNAME; FNM_PERIOD; and FNM_CASEFOLD.] |
fnmatch() : returns TRUE if there is a match; FALSE otherwise. At present, this function is unavailable on non-POSIX-compliant systems except for Windows. |
fopen()
[fopen – Opens file or URL] |
fopen() binds the named resource – specified by filename – to a stream. On encountering a filename of the form scheme://... , PHP assumes this is a URL and searches for a protocol handler for that scheme; if no such handlers are registered, PHP emits a notice and continues as if filename specifies a regular file. If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled; if disabled, PHP will emit a warning and the fopen() call will fail. If PHP has decided that filename specifies a local file, it will try to open a stream on that file. |
fopen(filename, mode, use_include_path [optional parameter], resource_context [optional parameter]);
[The optional use_include_path parameter can be set to 1 or TRUE if you want to search for the file in the |
fopen() : returns a file pointer resource on success; FALSE and a suppressable[-with-@] E_WARNING on failure. When connecting to a Microsoft IIS server using SSL, IIS will violate the protocol by closing the connection without sending a close_notify indicator. For PHP to work around this, error_reporting should be lowered to a level that does not include warnings. When using the https:// wrapper, PHP will suppress the warnings. If using fsockopen() to create an ssl:// socket, the developer is responsible for detecting and suppressing this warning. |
fpassthru()
[fpassthru – Output all remaining data on a file pointer] |
This function reads from the current position to the end of the file_pointer [‘passes through’] and writes the results to the output buffer. If you have already written data to the file, you may need to call rewind() to reset file_pointer to the beginning of the file. To simply dump the contents of a file to the output buffer without first modifying it/seeking to a particular offset, the readfile() function might be more efficient (since it doesn’t require the fopen() call). |
fpassthru(file_pointer); |
fpassthru() : returns the number of characters read from file_pointer and passed through to the output on success; FALSE on failure. |
fputcsv()
[fputcsv – Format line as CSV and write to file pointer] |
This function formats a line – passed as a fields array – as CSV and writes it [‘puts it’] (terminated by a newline) to file_pointer. | fputcsv(file_pointer, fields, delimiter [optional single-character parameter with a default value of “,“], enclosure [optional single-character parameter with a default value of ‘“”‘], escape_char [optional single-character parameter with a default value of “\“]); |
fputcsv() : returns the length of the written string on success; FALSE on failure. |
fread()
[fread – Binary-safe file read] |
This function reads up to length bytes from file_pointer. Reading stops as soon as: 1.) length bytes have been read; OR 2.) end-of-file is reached; OR 3.) a packet becomes available or a socket_timeout occurs; OR 4.) if the stream is read buffered and it does not represent a plain file, at most one read of up to a number of bytes equal to the chunk size (usually 8192) is made – depending on the previously buffered data, the size of the returned data may be larger than the chunk size. |
fread(file_pointer, length); |
fread() : returns the read string on success; FALSE on failure. The file must be opened with ‘b’ included in the fopen() mode parameter on systems that differentiate between binary and text files. Reading starts from the current position in the file_pointer; this position is specified by the ftell() function. Reading stops when a packet becomes available on streams returned when reading remote files, or when using popen() or fsockopen() . |
fscanf()
[fscanf – Parses input from a file according to a format] |
This function takes its input [‘scans’] from a file associated with file_pointer and interprets the input according to format. Each call to fscanf() reads one line from the file, and any whitespace in the format string matches any whitespace in the input stream. |
fscanf(file_pointer, format, args [optional parameter – the optional, assigned values]); |
fscanf() : returns an array of the values parsed if only two parameters were passed to this function; if optional parameters are passed, the number of assigned values will be returned. The optional parameters must be passed by reference. |
fseek()
[fseek – Seeks on a file pointer] |
This function sets the file position indicator for the file referenced by file_pointer. The new position is obtained by adding offset to the position specified by whence, and is measured in bytes from the beginning of the file. Although generally allowed, certain streams may not support seeking past end-of-file [EOF]. If data is written after seeking past EOF, reads in any unwritten region between EOF and the sought position will yield bytes with value 0. | fseek(file_pointer, offset, whence [optional parameter, with a default value of SEEK_SET]);
[offset: to move to a position before EOF, a negative value is required for offset and whence must be set to SEEK_END. whence possible values: SEEK_SET [set position equal to offset bytes]; SEEK_CUR [set position to current location plus offset]; and SEEK_END [set position to EOF plus offset].] |
fseek() : returns 0 on success; -1 on failure. |
fstat()
[fstat – Gets information about a file using an open file pointer] |
This function collects the statistics of the file opened by file_pointer. It is similar to the stat() function, but operates on an open file pointer rather than a filename.Will not work on remote files, since the file under examination needs to be accessible via the server’s filesystem. |
fstat(file_pointer); |
fstat() : returns an array with the statistics of the file. The array elements [numeric/associative] comprise: device number [0/dev]; inode number [1/ino]; inode protection mode [2/mode]; number of links [3/nlink]; userid of owner [4/uid]; groupid of owner [5/gid]; device type, if inode device [6/rdev]; size in bytes [7/size]; time of last access (Unix timestamp) [8/atime]; time of last modification (Unix timestamp) [9/mtime]; time of last inode change (Unix timestamp) [10/ctime]; blocksize of filesystem IO [11/blksize]; and number of 512-byte blocks allocated [12/blocks]. |
ftell()
[ftell – Returns the current position of the file read/write pointer] |
This function returns [‘tells’] the position of file_pointer. | ftell(file_pointer); |
ftell() : returns the position (as byte-based offset into the file stream) of file_pointer. |
ftruncate()
[ftruncate – Truncates a file to a given length] |
This function truncates the file referenced by file_pointer to size. | ftruncate(file_pointer, size);
[size: if larger than file_pointer then the file is extended with null bytes; if smaller than file_pointer then the file is truncated to that size.] |
ftruncate() : returns TRUE on success; FALSE on failure. |
fwrite()
[fwrite – Binary-safe file write] |
This function – an alias of fputs() – writes the contents of string to the file stream pointed to by file_pointer. |
fwrite(file_pointer, string, length [optional parameter]);
[If the length argument is given, writing will stop once length bytes have been written, or the end of string is reached [whichever comes first]. Also, the |
fwrite() : returns the number of bytes written on success; FALSE on failure. |
glob()
[glob – Find pathnames matching a pattern] |
This function searches for all the pathnames [thus, a global search] matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells. |
glob(pattern, flags [optional parameter]);
[With regard to pattern, no tilde expansion or parameter substitution is done. The following values can be used as the flags parameter: GLOB_MARK; GLOB_NOSORT; GLOB_NOCHECK; GLOB_NOESCAPE; GLOB_BRACE; GLOB_ONLYDIR; and GLOB_ERR.] |
glob() : returns an array containing the matched files or directories, or an empty array if no file matched; FALSE on error. |
is_dir()
[is_dir – Tells whether the filename is a directory] |
This function determines whether the given filename is a directory. | is_dir(filename);
[filename specifies the path to the file. If it is a relative filename it will be checked relative to the current working directory. If it is a symbolic or hard link, then the link will be resolved and checked. Further restrictions may apply if you have enabled |
is_dir() : returns TRUE if filename exists and is a directory; FALSE otherwise. An E_WARNING is emitted upon failure. |
is_executable()
[is_executable – Tells whether the filename is executable] |
This function determines whether filename is executable. | is_executable(filename); |
is_executable() : returns TRUE if filename exists and is executable; otherwise FALSE. An E_WARNING is emitted upon failure. |
is_file()
[is_file – Tells whether the filename is a regular file] |
This function determines whether filename is a regular file. | is_file(filename); |
is_file() : returns TRUE if filename exists and is a regular file; otherwise FALSE. An E_WARNING is emitted upon failure. Some filesystem functions may generate unexpected results for files in excess of 2GB, owing to the fact that PHP’s integer type is signed and many platforms use 32-bit integers. |
is_link()
[is_link – Tells whether the filename is a symbolic link] |
This function determines whether filename is a symbolic link. | is_link(filename); |
is_link() : returns TRUE if file exists and is a symbolic link; FALSE otherwise. An E_WARNING is emitted upon failure. |
is_readable()
[is_readable – Tells whether a file exists and is readable] |
This function determines whether a file exists and is readable. PHP may be accessing this file as the user id that the web server runs on; the check is done using the real UID/GID, rather than the effective one. The is_dir() function can be used to distinguish between files and directories. |
is_readable(filename); |
is_readable() : returns TRUE if the file or directory specified by filename exists and is readable; FALSE otherwise. An E_WARNING is emitted upon failure. |
is_uploaded_file()
[is_uploaded_file – Tells whether the file was uploaded via HTTP POST] |
This function determines if filename is a file that has been uploaded via HTTP POST. This function helps to ensure that a malicious user hasn’t tried to trick the script into working on files upon which it shouldn’t be working. For full functionality, is_uploaded_file() needs a correctly-phrased argument such as $_FILES['userfile']['tmp_name'] . |
is_uploaded_file(filename); |
is_uploaded_file() : returns TRUE on success; FALSE on failure. |
is_writable()
[is_writable – Tells whether the filename is writable] |
This function – an alias of is_writeable() – determines whether filename exists and is writable. filename may also be a directory name, thus enabling you to test whether a given directory is writable.PHP may be accessing the file as the user id that the web server runs on [often ‘nobody’]; safe mode limitations are not taken into account. |
is_writable(filename); |
is_writable() : returns TRUE if filename exists and is writable; otherwise FALSE. An E_WARNING is emitted upon failure. |
lchgrp()
[lchgrp – Changes group ownership of symlink] |
This function attempts to change the group of the symlink filename to group. Only the superuser may change the symlink group arbitrarily; other users may change the symlink group to any group of which they are a member. | lchgroup(filename, group); |
lchgrp() : returns TRUE on success; FALSE on failure. This function is not implemented on Windows platforms. When safe mode is enabled, PHP checks whether the files or directories being operated on have the same UID as the script that is being executed. |
lchown()
[lchown – Changes user ownership of symlink] |
This function attempts to change the owner of the symlink filename to user user. Only the superuser may change the owner of a symlink. | lchown(filename, user); |
lchown() : returns TRUE on success; FALSE on failure. As with lchgrp() , this function is not implemented on Windows; similarly, PHP checks for a match between the UID of filename and the UID of the currently-executing script when safe mode is enabled. |
link()
[link – Create a hard link] |
This function attempts to create a hard link between target and link. | link(target, link); |
link() : returns TRUE on success; FALSE on failure. On Windows systems, this function requires PHP to run in an elevated mode or with the UAC disabled. |
linkinfo()
[linkinfo – Gets information about a link] |
This function collects information about a link. It is used to verify that a link – pointed to by path – really exists [using the same method as the S_ISLNK macro defined in stat.h ]. |
linkinfo(path); |
linkinfo() : returns the st_dev field of the Unix C stat structure returned by the lstat() system call. Returns -1 [per http://man7.org/linux/man-pages/man2/stat.2.html] or FALSE in case of error. |
lstat()
[lstat – Gives information about a file or symbolic link] |
This function collects the statistics pertaining to the file or symbolic link referenced by filename. | lstat(filename); |
lstat() : returns an array structured as outlined above in relation to fstat() , relating to the file or symbolic link referenced by filename. |
mkdir()
[mkdir – Makes directory] |
This function attempts to create [‘make’] the directory specified by pathname. When safe mode is enabled, PHP checks that the directory in which the script is operating has the same UID as the currently-executing script. |
mkdir(pathname, mode [optional parameter with a default value of 0777], recursive [optional parameter, with a default value of FALSE], context [optional parameter]);
[mode is ignored on Windows. recursive allows the creation of nested directories specified in pathname.] |
mkdir() : returns TRUE on success; FALSE on failure. An E_WARNING is emitted if 1.) the directory already exists, and/or 2.) the relevant permissions prevent creating the directory. |
move_uploaded_file()
[move_uploaded_file – Moves an uploaded file to a new location] |
This function checks that the file referenced by filename is a valid file that was uploaded via PHP’s HTTP POST upload mechanism. If valid, the file will be moved to the filename specified by destination. If the destination file already exists it will be overwritten. |
move_uploaded_file(filename, destination); |
move_uploaded_file() : returns TRUE on success. No action will occur and FALSE will be returned if filename is not a valid upload file. FALSE will also be returned if filename cannot be moved for some reason – in this instance, no action will occur and a WARNING will be emitted. |
parse_ini_file()
[parse_ini_file – Parse a configuration file] |
This function loads in [‘parses’] the ini file specified in filename and returns the settings in it in an associative array. The structure of the ini file is the same as that of php.ini . |
parse_ini_file(filename, process_sections [optional parameter with a default value of FALSE], scanner_mode [optional parameter with a default value of INI_SCANNER_NORMAL ]);
[If process_sections is set to TRUE, a multidimensional array is returned – with section names and settings included. If |
parse_ini_file() : the settings are returned as an associative array on success; FALSE on failure. This function can be used to read in your own application’s configuration files. Any ini file values containing non-alphanumeric characters need to be enclosed in double quotes. Entries without an equals sign are ignored. |
parse_ini_string()
[parse_ini_string – Parse a configuration string] |
This function reads [‘parses’] the settings in ini_string and returns them in an associative array. The structure of ini_string is the same as that of php.ini . |
parse_ini_string(ini_string, process_sections [optional parameter with a default value of FALSE], scanner_mode [optional parameter with a default value of INI_SCANNER_NORMAL]);
[The same observations apply for |
parse_ini_string() : the settings are returned as an associative array on success; FALSE on failure. |
pathinfo()
[pathinfo – Returns information about a file path] |
This function returns information about path – either as an associative array or a string, depending on options. Since this function is locale-aware, the matching locale must be set for it to parse a path containing multibyte characters correctly. | pathinfo(path, options [optional parameter]);
[path represents the path to be parsed. options specifies a particular element to be returned: PATHINFO_DIRNAME; PATHINFO_BASENAME; PATHINFO_EXTENSION; or PATHINFO_FILENAME. |
pathinfo() : depends upon the options parameter. If options is not specified, an associative array containing the following elements is returned: dirname; basename; extension [if any]; and filename. |
popen()
[popen – Opens process file pointer] |
This function opens a pipe to a process executed by forking the command given by command. | popen(command, mode); |
popen() : returns a file pointer identical to that returned by fopen() , except that it is unidirectional and may only be closed with pclose() . This pointer may be used with fgets() , fgetss() , and fwrite() .The returned file pointer is equal to the STDOUT of the command when mode is ‘r’; when the mode is ‘w’ the returned file pointer is equal to the STDIN of the command. FALSE is returned upon error. |
pclose()
[pclose – Closes process file pointer] |
This function closes a file pointer to a pipe opened by popen() . |
pclose(resource_handle); |
pclose() : returns the termination status of the process that was run, as an integer.-1 is returned if an error occurs. |
readfile()
[readfile – Outputs a file] |
This function reads a file and writes it to the output buffer. | readfile(filename, use_include_path [optional parameter with a default value of FALSE], context [optional parameter]);
[Set use_include_path to TRUE if you want to search for filename in the |
readfile() : returns the number of bytes read from the file on success; FALSE and an error message on failure. |
realpath_cache_get()
[realpath_cache_get – Get realpath cache entries] |
This function gets the contents of the realpath cache. | realpath_cache_get(); |
realpath_cache_get() : returns an array of realpath cache entries. The keys are original path entries and the values are arrays of data items, containing the resolved path, expiration date, and other options kept in the cache. |
realpath_cache_size()
[realpath_cache_size – Get realpath cache size] |
This function gets the amount [‘size’] of memory used by the realpath cache. | realpath_cache_size() ; |
realpath_cache_size() : returns the amount of memory realpath cache is using. |
realpath()
[realpath – Returns canonicalized absolute pathname] |
This function expands all symbolic links and resolves references to /./,/../ and extra / characters in the input path and returns the canonicalized absolute pathname [‘realpath’]. For case-insensitive filesystems, realpath() might or might not normalize the character case. realpath() will not work on a file that is inside a Phar as such a path would be a virtual one NOT a real one. |
realpath(path) ;
[If an empty string is passed as the path parameter, the value is interpreted as the current directory.] |
realpath() : returns the canonicalized absolute pathname on success; FALSE on failure. The resulting path will have no symbolic link, /./ or /../ components; trailing delimiters – such as \ and / – are also removed. The running script must have execute permissions on all directories in the hierarchy, otherwise FALSE will be returned. |
readlink()
[readlink – Returns the target of a symbolic link] |
This function does the same as the readlink C function. |
readlink(path) ; |
readlink() : returns the contents of the symbolic link path on success; FALSE on error. |
rename()
[rename – Renames a file or directory] |
This function attempts to rename oldname to newname, moving it between directories if necessary. If newname exists when renaming a file, it will be overwritten. If newname exists when renaming a directory, a warning will be emitted. The wrapper used in oldname MUST match the wrapper used in newname. | rename(oldname, newname, context [optional parameter]) ; |
rename() : returns TRUE on success; FALSE on failure. |
rewind()
[rewind – Rewind the position of a file pointer] |
This function sets the file position indicator for handle to the beginning of the file stream [thus, it ‘rewinds’ the file position indicator]. Any data written to a file that was opened in append mode [‘a’, ‘a+’] will always be appended to the file, regardless of the file position indicator. | rewind(handle) ; |
rewind() : returns TRUE on success; FALSE on failure. |
rmdir()
[rmdir – Removes directory] |
This function attempts to remove the directory named by dirname. The relevant permissions must permit this, and dirname must be empty. | rmdir(dirname, context [optional parameter]) ; |
rmdir() : returns TRUE on success; FALSE and an E_WARNING on failure. |
stream_set_write_buffer()
[stream_set_write_buffer – Sets write file buffering on the local stream] |
This function – an alias of set_file_buffer() – sets the buffering for write operations on the given stream to buffer bytes. |
stream_set_write_buffer(stream, buffer) ;
[stream represents the file pointer. buffer represents the number of bytes to buffer; if 0 then write operations are unbuffered – this ensures that all writes with |
stream_set_write_buffer() : returns 0 on success; another value if the request cannot be honoured. |
stat()
[stat – Gives information about a file] |
This function collects the statistics pertaining to the file specified by filename. If filename is a symbolic link, statistics relate to the file itself, not the symlink; lstat() is identical to stat() except that its statistics would pertain to the symlink‘s status. |
stat(filename) ; |
stat() : returns an array of statistics pertaining to filename, as detailed in relation to fstat() above. Additional notes on the array elements returned by this function are: inode number [1/ino], userid of owner [4/uid], and groupid of owner [5/gid] will always be 0 on Windows platforms; blocksize of filesystem IO [11/blksize] and number of 512-byte blocks allocated [12/blocks] are only valid on systems supporting the st_blksize type — other systems (including Windows) return -1. FALSE is returned and an E_WARNING is emitted upon failure. |
symlink()
[symlink – Creates a symbolic link] |
This function creates a symbolic link to the existing target with the specified name link. | symlink(target, link) ; |
symlink() : returns TRUE on success; FALSE on failure. Regarding Windows performance: this function will only work if the system you run PHP from is Windows Vista/Windows Server 2008 or newer; prior Windows versions do not support symbolic links. |
tempnam()
[tempnam – Create file with unique file name] |
This function creates a file with a unique temporary filename – with access permission set to 0600 – in the specified directory. This function may generate a file in the system’s temporary directory – and return the full path to that file, including its name – if directory does not exist or is not writable. |
tempnam(directory, prefix) ;
[prefix represents the prefix of the generated temporary filename. Only the first three characters of prefix are used on Windows platforms.] |
tempnam() : returns the new temporary filename (with path) as a string on success; FALSE on failure. If you no longer require the created file you must remove it manually, it is not removed automatically. If PHP cannot create the file in the specified directory, it falls back on the system default. This also happens on NTFS if the specified directory contains more than 65534 files. |
tmpfile()
[tmpfile – Creates a temporary file] |
This function creates a temporary file with a unique name in read-write mode [‘w+’], and returns a file handle. The file is automatically removed when 1.) fclose() is called, or 2.) there are no remaining references to the file handle, or 3.) the script ends. For further details, consult your system documentation on the tmpfile(3) function, as well as the stdio.h header file. |
tmpfile() ; |
tmpfile() : returns a resource handle for the new file on success (similar to the one returned by fopen() ); FALSE on failure. |
touch()
[touch – Sets access and modification time of file] |
This function attempts to set the access and modification [‘touch’] times of the file named in filename to the value given in time. Regardless of the number of parameters, the access time is always modified. The file will be created if it does not already exist. |
touch(filename, time [optional parameter, with a default value of time() ], atime [optional parameter]);
[atime: the access time of filename is set to atime, if present. Otherwise, it is set to the value passed in time. The current system time is used if neither value is present.] |
touch() : returns TRUE on success; FALSE on failure. Prior to PHP 5.3.0 it was not possible to change the modification time of a directory with this function on Windows platforms. |
umask()
[umask – Changes the current umask] |
This function sets PHP’s umask to mask & 0777, and returns the old umask. When PHP is being used as a server module, the umask is restored when each request is finished. | umask(mask [optional parameter]);
[If mask is not supplied, the current umask is returned.] |
umask() : if mask is present, the old umask is returned; if mask is absent, the current umask is returned. |
unlink()
[unlink – Deletes a file] |
This function deletes [‘un–links’] filename; similar to the Unix C unlink() function. |
unlink(filename, context [optional parameter]); |
unlink() : returns TRUE on success; FALSE and an E_WARNING on failure. |
FILL IN FORM AND CLICK SUBMIT TO ADD YOUR STATISTICS TO THE LEADERBOARD:
Forty-year-old father of three wonderful children [William, Seth, and Alyssa]. Works as an Assistant Technical Officer in the Sterile Services Department of Treliske Hospital, Cornwall. Enjoys jogging, web design, learning programming languages, and supporting Arsenal FC. Obtained a BA degree in English from the University of Bolton in 2008, and has continued to gain qualifications in a diverse range of subjects thereafter.