Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
92 Cards in this Set
- Front
- Back
__LINE__
|
Magic constant
The current line number of the file. |
|
__FILE__
|
Magic constant
The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances. |
|
__FUNCTION__
|
Magic constant
The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased. |
|
__CLASS__
|
Magic constant
The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased. |
|
__METHOD__
|
Magic constant
The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive). |
|
php.* stream
|
standard PHP input/output
|
|
file stream
|
standard file access
|
|
http stream
|
access to remote resources via HTTP
|
|
ftp stream
|
access to remote resources via FTP
|
|
compress.zlib stream
|
access to compressed data stream using the zlib compression library.
|
|
Stream Filters
|
several stream extensions that can be “installed” on top of the existing one to form chains of filters that act cumulatively on a data stream
|
|
string.rot13
|
Stream filter
encodes the data stream using the ROT-13 algorithm |
|
string.toupper
|
Stream filter
converts strings to uppercase |
|
string.tolower
|
Stream filter
converts strings to lowercase |
|
string.strip_tags
|
Stream filter
removes XML tags from a stream |
|
convert.*
|
Stream filter
a family of filters that converts to and from the base64 encoding. |
|
mcrypt.*
|
Stream filter
a family of filters that encrypts and decrypts data according to multiple algorithms |
|
zlib.*
|
Stream filter
a family of filters that compressed and decompresses data using the zlib compression library |
|
r
|
fopen() argument
Opens the file for reading only and places the file pointer at the beginning of the file |
|
r+
|
fopen() argument
Opens the file for reading and writing; places the file pointer at the beginning of the file |
|
w
|
fopen() argument
Opens the file for writing only; places the file pointer at the beginning of the file and truncate it to zero length Automatically create a new file if it doesn’t yet exist |
|
w+
|
fopen() argument
Opens the file for writing and reading; places the file pointer at the beginning of the file and truncate it to zero length Automatically create a new file if it doesn’t yet exist |
|
a
|
fopen() argument
Opens the file for writing only; places the file pointer at the end of the file Automatically create a new file if it doesn’t yet exist |
|
a+
|
fopen() argument
Opens the file for reading and writing; places the file pointer at the end of the file Automatically create a new file if it doesn’t yet exist |
|
x
|
fopen() argument
Creates a new file for writing only Throws an E_WARNING if the file already exists |
|
x+
|
fopen() argument
Creates a new file for reading and writing Throws an E_WARNING if the file already exists |
|
b flag
|
Coupled with fopen argument
Forces “binary” mode, which will make sure that all data is written to the file unaltered |
|
t flag
|
Coupled with fopen argument
Windows only transparently translate UNIX newlines (\n) to Windows newlines (\r\n) |
|
fopen
|
Opens file or URL
( string $filename, string $mode [, bool $use_include_path [, resource $context]] ) |
|
fread
|
Binary-safe file read
reads up to length bytes from the file pointer referenced by handle. Reading stops when up to length bytes have been read, EOF (end of file) is reached, (for network streams) when a packet becomes available, or (after opening user space stream) when 8192 bytes have been read whichever comes first. ( resource $handle, int $length ) |
|
fgets
|
Gets a line from file pointer.
Reading ends when length – 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first). If no length is specified, it will keep reading from the stream until it reaches the end of the line. ( resource $handle [, int $length] ) |
|
fwrite
|
Binary-safe file write returns the number of bytes written, or FALSE on error.
Writes the contents of string to the file stream pointed to by handle. If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first. Note that if the length argument is given, then the magic_quotes_runtime configuration option will be ignored and no slashes will be stripped from string. ( resource $handle, string $string [, int $length] ) |
|
fstat
|
Gathers the statistics of the file opened by the file pointer handle . This function is similar to the stat() function except that it operates on an open file pointer instead of a filename.
( resource $handle ) |
|
stat
|
Gathers the statistics of the file named by filename . If filename is a symbolic link, statistics are from the file itself, not the symlink.
( string $filename ) |
|
lstat
|
Gathers the statistics of the file or symbolic link named by filename .
This function is identical to the stat() function except that if the filename parameter is a symbolic link, the status of the symbolic link is returned, not the status of the file pointed to by the symbolic link. ( string $filename ) |
|
file_exists
|
Checks whether a file or directory exists.
( string $filename ) |
|
flock
|
flock() allows you to perform a simple reader/writer model which can be used on virtually every platform (including most Unix derivatives and even Windows).
The lock is released also by fclose() (which is also called automatically when script finished). PHP supports a portable way of locking complete files in an advisory way (which means all accessing programs have to use the same way of locking or it will not work). By default, this function will block until the requested lock is acquired; this may be controlled (on non-Windows platforms) with the LOCK_NB option. ( resource $handle , int $operation [, int &$wouldblock ] ) |
|
LOCK_SH
|
flock locking operation
to acquire a shared lock (reader). |
|
LOCK_EX
|
flock locking operation
to acquire an exclusive lock (writer). |
|
LOCK_UN
|
flock locking operation
to release a lock (shared or exclusive). |
|
LOCK_NB
|
flock locking operation
if you don't want flock() to block while locking. (not supported on Windows) |
|
fseek
|
Sets the file position indicator for the file referenced by handle . The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence .
Offset: When your starting position is SEEK_END, this number should always be zero or less, while, when you use SEEK_SET, it should always be zero or more. When you specify SEEK_CURRENT as a starting point, the value can be either positive (move forward) or negative (move backwards)—in this case, a value of zero, while perfectly legal, makes no sense. Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an error. ( resource $handle, int $offset [, int $whence] ) |
|
ftell
|
Returns the position of the file pointer referenced by handle .
( resource $handle ) gives undefined results for append-only streams (opened with “a” flag). |
|
feof
|
Tests for end-of-file on a file pointer.
Returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE. ( resource $handle ) |
|
ftruncate
|
Takes the filepointer, handle , and truncates the file to length, size .
Truncates a file to a given length The file pointer is changed only in append mode. In write mode, additional fseek() call is needed. ( resource $handle, int $size ) |
|
fgetcsv
|
Gets line from file pointer and parse for CSV fields.
Similar to fgets() except that fgetcsv() parses the line it reads for fields in CSV format and returns an array containing the fields read. ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] ) |
|
fputcsv
|
Format line as CSV and write to file pointer.
If you don’t specify a delimiter and an enclosure character, both fgetcsv() and fputcsv() use a comma and quotation marks respectively. ( resource $handle, array $fields [, string $delimiter [, string $enclosure]] ) |
|
readfile
|
Outputs a file.
Reads a file and writes it to the output buffer. Returns the number of bytes read from the file. If an error occurs, FALSE is returned and unless the function was called as @readfile(), an error message is printed. ( string $filename [, bool $use_include_path [, resource $context]] ) |
|
fpassthru
|
Output all remaining data on a file pointer
Reads to EOF on the given file pointer from the current position and writes the results to the output buffer. You may need to call rewind() to reset the file pointer to the beginning of the file if you have already written data to the file. If you just want to dump the contents of a file to the output buffer, without first modifying it or seeking to a particular offset, you may want to use the readfile(), which saves you the fopen() call. ( resource $handle ) |
|
file
|
Reads an entire file into an array. Used with:
string implode ( string $glue, array $pieces ) ( string $filename [, int $flags [, resource $context]] ) |
|
file_get_contents
|
This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.
file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance. ( string $filename [, int $flags = 0 [, resource $context [, int $offset = -1 [, int $maxlen = -1 ]]]] ) Limit the amount of data read by file_get_contents() by specifying an appropriate set of parameters to the function. |
|
file_put_contents
|
This function is identical to calling fopen(), fwrite() and fclose() successively to write data to a file.
If filename does not exist, the file is created. Otherwise, the existing file is overwritten, unless the FILE_APPEND flags is set. Pass an array to file_put_contents() instead of a string. The function will automatically apply the equivalent of implode(“”, $data) on the $data array and write the resulting string to the file. In addition, it is possible to pass file_put_contents() a stream resource instead of a string or an array; in this case, the unread remainder of the stream will be placed in the file. |
|
basename
|
Returns filename component of path.
Given a string containing a path to a file, this function will return the base name of the file. If the optional suffix parameter is supplied, that suffix will be omitted if the returned file name contains that extension.Returns filename component of path. Given a string containing a path to a file, this function will return the base name of the file. If the optional suffix parameter is supplied, that suffix will be omitted if the returned file name contains that extension. ( string $path [, string $suffix] ) |
|
realpath
|
Returns canonicalized absolute pathname.
realpath() expands all symbolic links and resolves references to ‘/./’, ‘/../’ and extra ‘/’ characters in the input path. and return the canonicalized absolute pathname. |
|
chdir
|
Changes PHP’s current directory to directory.
( string $directory ) |
|
getcwd
|
Gets the current working directory.
On some Unix variants, getcwd() will return FALSE if any one of the parent directories does not have the readable or search mode set, even if the current directory does. |
|
unlink
|
Deletes filename
( string $filename [, resource $context] ) |
|
rename
|
Renames a file or directory
Attempts to rename oldname to newname. ( string $oldname, string $newname [, resource $context] ) |
|
rmdir
|
Attempts to remove the directory named by dirname. The directory must be empty, and the relevant permissions must permit this.
( string $dirname [, resource $context] ) |
|
mkdir
|
Attempts to create the directory specified by pathname.
Note that, normally. only the last directory in the path will be created, and mkdir() will fail if any other component of the path does not correspond to an existing directory. The third parameter to the function, however, allows you to override this behaviour and actually create anymissing directories along the line. The second parameter allows you to specify the access mode for the file—an integer parameter that most people prefer to specify in the UNIX-style octal notation. Note that this parameter is ignored under Windows, where access control mechanisms are different. ( string $pathname [, int $mode [, bool $recursive [, resource $context]]] ) |
|
is_dir
|
Tells whether the given filename is a directory.
( string $filename ) |
|
is_executable
|
Tells whether the filename is executable.
( string $filename ) |
|
is_file
|
Tells whether the given file is a regular file.
( string $filename ) |
|
is_link
|
Tells whether the given file is a symbolic link.
( string $filename ) |
|
is_readable
|
Tells whether the filename is readable.
( string $filename ) |
|
is_writable
|
Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writeable.
Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often ‘nobody’). Safe mode limitations are not taken into account. ( string $filename ) |
|
is_uploaded_file
|
Tells whether the file was uploaded via HTTP POST.
Returns TRUE if the file named by filename was uploaded via HTTP POST. This is useful to help ensure that a malicious user hasn’t tried to trick the script into working on files upon which it should not be working–for instance, /etc/passwd. This sort of check is especially important if there is any chance that anything done with uploaded files could reveal their contents to the user, or even to other users on the same system. For proper working, the function is_uploaded_file() needs an argument like $_FILES['userfile']['tmp_name'], – the name of the uploaded file on the clients machine $_FILES['userfile']['name'] does not work. ( string $filename ) |
|
clearstatcache
|
When you use stat(), lstat(), or any of the other functions listed in the affected functions list (below), PHP caches the information those functions return in order to provide faster performance. However, in certain cases, you may want to clear the cached information. For instance, if the same file is being checked multiple times within a single script, and that file is in danger of being removed or changed during that script's operation, you may elect to clear the status cache. In these cases, you can use the clearstatcache() function to clear the information that PHP caches about a file.
You should also note that PHP doesn't cache information about non-existent files. So, if you call file_exists() on a file that doesn't exist, it will return FALSE until you create the file. If you create the file, it will return TRUE even if you then delete the file. However unlink() clears the cache automatically. ([ bool $clear_realpath_cache = false [, string $filename ]] ) |
|
move_uploaded_file
|
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP’s HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE. If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued. ( string $filename, string $destination ) |
|
link
|
Create a hard link.
( string $target, string $link ) |
|
symlink
|
creates a symbolic link to the existing target with the specified name link.
( string $target, string $link ) |
|
readlink
|
Returns the target of a symbolic link.
( string $path ) |
|
disk_free_space
|
Given a string containing a directory, this function will return the number of bytes available on the corresponding filesystem or disk partition.
( string $directory ) |
|
readdir
|
Read entry from directory handle.
Returns the filename of the next file from the directory. The filenames are returned in the order in which they are stored by the filesystem. ( resource $dir_handle ) |
|
scandir
|
Returns an array of files and directories from the directory.
( string $directory [, int $sorting_order [, resource $context]] ) |
|
filectime/filemtime
|
The “last changed time” differs from the “last modified time” in that the last changed time refers to any change in the file’s inode data, including changes to permissions, owner, group, or other inode-specific information, whereas the last modified time refers to changes to the file’s content (specifically, byte size).
(string filename) |
|
fileperms
|
The fileperms() function returns filename’s permissions in decimal format, or FALSE in case of error. Because the decimal permissions representation is almost certainly not the desired format, you’ll need to convert fileperms()’s return value. This is easily accomplished using the base_convert() function in conjunction with substr(). The base_convert() function converts a value from one number base to another; therefore, you can use it to convert fileperms()’s returned decimal value from base 10 to the desired base 8. The substr() function is then used to retrieve only the final three digits of base_convert()’s returned value, which are the only digits referred to when discussing Unix file permissions.
(string filename) |
|
Stream Components
|
– file wrapper
– one or two pipe-lines – an optional context – metadata about the stream |
|
stream_get_meta_data
|
Retrieves header/meta data about an existing stream .
( resource $stream ) |
|
stream_context_create
|
Creates and returns a stream context with any options supplied in options preset.
Using stream context and a few other techniques a lot can be done without resorting to sockets, however for more detailed control sockets can be used. Sockets allow read/write access to various socket connections, while things like HTTP may seem read only, at the protocol level information is being sent to identify the desired resource. ([ array $options [, array $params ]] ) |
|
fsockopen
|
Open Internet or Unix domain socket connection.
( string $hostname [, int $port [, int &$errno [, string &$errstr [, float $timeout]]]] ) |
|
stream_socket_server
|
Creates a stream or datagram socket on the specified local_socket .
This function only creates a socket, to begin accepting connections use stream_socket_accept(). ( string $local_socket [, int &$errno [, string &$errstr [, int $flags [, resource $context]]]] ) |
|
stream_get_transports
|
Returns an indexed array containing the name of all socket transports available on the running system.
|
|
stream_socket_accept
|
Accept a connection on a socket previously created by stream_socket_server(). If timeout is specified, the default socket accept timeout will be overridden with the time specified in seconds. The name (address) of the client which connected will be passed back in peername if included and available from the selected transport.
peername can also be determined later using stream_socket_get_name(). ( resource $server_socket [, float $timeout [, string &$peername]] ) |
|
stream_get_wrappers
|
Retrieve list of registered streams
Returns an indexed array containing the name of all stream wrappers available on the running system. |
|
stream_wrapper_register
|
Register a URL wrapper implemented as a PHP class
( string $protocol, string $classname ) |
|
stream_socket_client
|
Initiates a stream or datagram connection to the destination specified by remote_socket . The type of socket created is determined by the transport specified using standard URL formatting: transport://target. For Internet Domain sockets (AF_INET) such as TCP and UDP, the target portion of the remote_socket parameter should consist of a hostname or IP address followed by a colon and a port number. For Unix domain sockets, the target portion should point to the socket file on the filesystem.
( string $remote_socket [, int &$errno [, string &$errstr [, float $timeout [, int $flags [, resource $context]]]]] ) |
|
stream_socket_get_name
|
Retrieve the name of the local or remote sockets
Returns the local or remote name of a given socket connection. If want_peer is set to TRUE the remote socket name will be returned, if it is set to FALSE the local socket name will be returned. ( resource $handle, bool $want_peer ) |
|
stream_filter_register
|
Register a stream filter implemented as a PHP class derived from php_user_filter
( string $filtername, string $classname ) |
|
stream_filter_prepend
|
Adds filtername to the list of filters attached to stream .
( resource $stream , string $filtername [, int $read_write [, mixed $params ]] ) |
|
stream_filter_append
|
Adds filtername to the list of filters attached to stream .
( resource $stream, string $filtername [, int $read_write [, mixed $params]] ) |
|
Steps to create a socket
|
1. Install a Phone - socket_create()
2. Plug in the phone to the phone jack - socket_bind() 3. Turn the power to the phone on - socket_listen() 4. When the phone rings, you pick it up and talk! - socket_accept() |