18.1. PHP
The following is the
quick reference guide to PHP. This list is complete as of PHP 3. The
functions that work with MySQL and mSQL are covered, but those
specific to other database servers -- such as Ababas D, dbm,
Oracle, and PostgreSQL -- are omitted.
Returns the absolute value of number.
$escaped_string = addslashes($string); | |
Returns a copy of string with any
$ \ or ' characters escaped.
$sorted_array = asort($array);
| |
Returns a sorted copy of the associative array
array. asort works only on
associative arrays. Use sort to sort regular
arrays. If the first member of the array is a number the returned
array will be sorted numerically, otherwise the returned array will
be sorted alphabetically.
$decimal = bindec($binary);
| |
Returns the decimal equivalent of binary.
$higher_integer = ceil($number);
| |
Rounds number to the next highest integer and
returns that as a floating point value.
Changes the current working directory to directory.
Changes the file file to belong to the group
group.
chimed($file,$permissions);
| |
Changes the file to have the permissions
permissions. The permissions argument must be
given as an octal value.
Changes the file to belong to the owner owner.
This function takes effect only if the PHP binary is running as root,
which is not generally recommended.
$stripped_string = chop($string);
| |
Returns string with all trailing new lines,
spaces, and tabs removed.
$character = chr($number);
| |
Returns the character that corresponds to the ASCII value of
number. Hexadecimal and octal numbers are denoted
with the usual 0xff and 077 respectively. All other numbers are
considered decimal.
Empties the current stack. This function is a kludge designed to
circumvent a limitation in the design of PHP. If you have a
user-defined function that contains a large loop, you may run into
stack space problems. If this happens, call this function inside the
loop. The drawback of doing this is that your function cannot be
called within another function. The output of your function has to be
saved to a variable which then can be used as you wish.
Empties the cache used for any functions that access information
about files. Because accessing file information can take a relatively
long time, this information is stored in a cache by PHP. If you want
to be sure you are getting the most current (i.e., noncached)
information about a file, call this function before retrieving the
information.
Closes a directory opened with opendir.
Stops all logging done via syslog.
Returns the cosine of number.
Returns the number of elements in array. If
array is a nonarray variable, the function returns
1 (because a variable looks like an array with only one element). If
array is not defined,
is returned.
$encrypted_string = crypt($string);
$encrypted_string = crypt($string, $salt); | |
Returns an encrypted version of string. The
encryption is the standard Unix DES encryption as used in Unix
passwords and the like. An optional two-character salt can be
provided.
$formatted_date = date($format,$time);
| |
Returns time (a standard Unix time as given by the
Time function) formatted with format. The returned
value is the same as format except that the
following characters are replaced with the appropriate value:
- A
AM/PM
- a
am/pm
- D
Day (eg., Sun)
- d
Day (eg., 13)
- F
Month (eg., February)
- H
Hours in 24 hour format (eg., 17)
- h
Hours in 12 hour format (eg., 5)
- i
Minutes (eg., 30)
- l
Day (eg., Sunday)
- M
Month (eg., Feb)
- m
Month (eg., 02)
- s
Seconds (eg., 27)
- Y
Year (eg., 1998)
- y
Year (eg., 98)
- U
Seconds since epoch (eg., 803537321)
- z
Day of the year (eg., 154)
Returns a list of the databases supported by PHP.
$binary = decbin($decimal); | |
Returns the binary equivalent of decimal.
Returns the hexadecimal equivalent of decimal.
$octal = decoct($decimal); | |
Returns the octal equivalent of decimal.
$double = doubleval($variable); | |
Returns variable as a floating point number.
echo [format_string] expression [, expression ...] | |
This is not a true function but rather PHP's built-in version
of the C printf function. In its simplest form,
echo simply prints out
expression. Up to 5 expressions can be given, each
of which are printed out in turn. In addition, a format string can be
provided. The format string is in the same style as C or Perl's
printf function.
Sets the internal pointer of array to the end of
the array.
$result = ereg($expression, $string); | |
$result = ereg($expression, $string, $match_array);
Returns a true value if string matches the regular
expression expression. If an array is provided as
the third argument, the values matched in the string are placed in
the array.
$result = eregi($expression, $string);
$result = eregi($expression, $string, $match_array); | |
Identical to ereg except that case is ignored
for the purposes of matching.
ereg_replace($expression, $replacement_string, $string); | |
Replaces all parts of string that match
expression with
replacement_string.
eregi_replace($expression, $replacement_string, $string); | |
Identical to ereg_replace except that case is
ignored for the purposes of matching.
$safe_string = escapeshellcmd($string); | |
Returns a copy of string with its characters
escaped so that it is safe for use with exec or
system.
Evaluates the contents of string as if it were a
PHP script. Variable substitution is done on the string so if you
want to use a variable in the "miniscript" you should
escape it.
$last_line = exec($command);
$last_line = exec($command, $output_array);
$last_line = exec($command, $output_array, $return_code);
| |
$last_line = exec($command, $output_array);
Executes command as a Unix command in a subshell.
Only the last line of the command output is returned. If an array is
provided as the second argument, all of the lines of output from the
command are placed in the array. If a third argument is present, the
return code from the command is placed in that variable.
Ends all parsing of the HTML file.
Returns the number e raised to the
number power.
Closes a file opened by fopen.
Returns true if the file descriptor fd is at the
end of the file.
$line = fgets($fd, $max_bytes); | |
Returns the next line (up to max_bytes in length)
from the file referred to by fd.
$line = fgetss($fd, $max_bytes); | |
Identical to fgets except that it attempts to
strip all HTML and PHP tags from the input.
$array = file($filename); | |
Returns an array containing every line in the file
filename.
$time = fileatime($filename); | |
Returns (in standard Unix time format) the last time
filename was accessed. If this information cannot
be obtained for whatever reason, the function returns -1.
$time = filectime($filename); | |
Returns (in standard Unix time format) the last time
filename's status was changed. If this
information cannot be obtained for whatever reason, the function
returns -1.
$group_id = filegroup($filename); | |
Returns the group ID of filename's group. If this information
cannot be obtained for whatever reason, the function returns -1.
$inode = fileinode($filename); | |
Returns the inode of filename. If this information
cannot be obtained for whatever reason, the function returns -1.
$time = filemtime($filename); | |
Returns (in standard Unix time format) the last time
filename was modified. If this information cannot
be obtained for whatever reason, the function returns -1.
$owner = fileowner($filename); | |
Returns the ID of the owner of the file. If this information cannot
be obtained for whatever reason, the function returns -1.
$permissions = fileperms($filename); | |
Returns the permissions of filename. If this
information cannot be obtained for whatever reason, the function
returns -1.
$size = filesize($filename); | |
Returns the size of filename in bytes. If this
information cannot be obtained for whatever reason, the function
returns -1.
$type = filetype($filename); | |
Returns one of the following, indicating the type of
filename: dir,
file, fifo,
char, block, or
link.
$lower_integer = floor($number); | |
Rounds number to the next lowest integer and
returns that as a floating point value.
Flushes the buffer on the standard output so that the end user
immediately sees all of the output so far.
$fd = fopen($filename, $mode); | |
Opens the file filename in the mode mode and returns a file
descripter associated with the open file. As with the C function
fopen, the mode is one of "r",
"r+", "w", "w+", "a",
"a+". The function returns -1 if the file could not be
opened.
Writes string to the file associated with
fd, followed by a newline.
Directly prints all of the remaining data in the file associated with
fd.
Positions the file associated with fd to
position bytes from the beginning of the file.
$fd = fsockopen($hostname,$port); | |
Opens a connection with hostname on port
port and returns a file descriptor associated with
the open connection. If the port number is 0, the hostname will be
considered the filename of a Unix-style socket file on the local
host. In the case of an error, the function returns the following: -3
if the socket could not be created, -4 if the hostname could not be
resolved, -5 if the connection was refused or timed out, -6 if the
fdopen() call failed, or -7 if the setvbuf() call failed.
Returns the position of the pointer in the file associated with
fd. This value can be used as an argument to
fseek.
$directory = getaccdir(); | |
Returns the directory where the PHP configuration files are held.
$value = getenv($variable); | |
Returns the value of the environment variable
variable.
$address = gethostbyname($hostname); | |
Returns the IP address of hostname.
$hostname = gethostbyaddr($address); | |
Returns the hostname of the machine with the IP address
address.
$file_info_array = getimagesize($filename); | |
Returns an array of information about the image in the file
filename. The first element of the array is the
width of the image, the second is the height, and the third is the
type of the image. GIF, JPG, and PNG images are currently recognized.
The fourth element is a string of the format "width=xxx
height=yyy" which can be used directly in an HTML
<IMG> tag.
Returns (in standard Unix time format) the date and time the page was
last accessed. This function works only if PHP was compiled with
access logging enabled.
$browser = getlastbrowser(); | |
Returns the identification string of the last browser to access the
page. This function works only if PHP was compiled with access
logging enabled.
Returns the e-mail address of the last person to access the page.
This function works only if PHP was compiled with access logging
enabled.
Returns the hostname of the last machine to access the page. This
function works only if PHP was compiled with access logging enabled.
Returns the time (in standard Unix time format) that the page was
last modified. This function works only if PHP was compiled with
access logging enabled.
Returns the URL of the referring page of the last visitor to the
page. This function works only if PHP was compiled with access
logging enabled.
$directory = getlogdir(); | |
Returns the directory that contains the PHP log files.
Returns the inode of the HTML file that contains the current PHP
script.
Returns the process ID number of the current PHP process.
Returns the user ID of the owner of the HTML file that contains the
current PHP script.
Returns the largest possible number that will be returned by
rand.
$time = getstartlogging(); | |
Returns the time (in standard Unix format) that logging began on the
HTML file containing the current PHP script.
Returns the number of hits the page has received since midnight at
the beginning of the current day.
Returns the total number of hits the page has received since logging
was started on the page.
$type = gettype($variable);
Returns one of "integer," "double," or
"string," indicating the type of
variable.
$formatted_date = gmdate($format, $time); | |
Identical to Date except that it uses Greenwich Mean time to
calculate the values instead of the local time.
Outputs header_string as the HTTP header of the
document. This function must be used before any HTML in the file and
before any PHP commands which generate output.
Returns the decimal equivalent of hex.
$html_string = htmlspecialchars($string); | |
Returns string, replacing any special characters (including <,
>, &, " and all ASCII characters from 160 to 255) with
their HTML entity codes.
imagearc($image, $cx, $cy, $width, $height, $start, $end, $color); | |
Draws a partial ellipse in image with the color
color. The ellipse has the center
(cx, cy) width
width, height height, begins at
start degrees, and ends at end
degrees.
imagechar($image, $size, $x, $y, $character, $color); | |
Draws character in image with the color
color with the font size size.
The top left of character is at the point
(x, y).
imagecharup($image, $size, $x, $y, $character, $color); | |
Identical to imagechar except that the character
is drawn vertically with the bottom left at (x,
y).
$color = imagecolorallocate($image, $red, $green, $blue); | |
Returns a color for use with the image image using
the RGB components specified.
imagecolortransparent($image, $color); | |
Sets color as the transparent color for
image.
imagecopyresized($dest_image, $src_image, $dest_x, $dest_y, $src_x, $src_y,
$dest_width, $dest_heigth, $src_width, $src_heigth); | |
Copies a rectangular portion from src_image and
pastes it into dest_image, resizing if necessary.
The arguments dest_x and dest_y
are the coordinates of the top left of the rectangle for the
destination image, and dest_height and
dest_width are the height and width. The arguments
src_x, src_y, src_width, and
src_heigth are the corresponding values for the
source image.
$image = imagecreate($width, $height); | |
Returns an image indentifier representing a new image with the
specified height and width.
$image = imagecreatefromgif($filename); | |
Returns an image indentifier representing the image contained in the
file filename.
Frees any resources occupied by image.
imagefill($image, $x, $y, $color); | |
Flood fills image with the color
color starting at the point (x,
y).
imagefilledpolygon($image, $points_array, $num_points, $color); | |
Creates a polygon in image filled with the color
color. The second argument is an array of the
points of the polygon. The first two elements of the array are the x
and y values of the first point. The next two elements are the value
of the next point, and so on. The third argument is the number of
points in the polygon.
imagefilledrectangle($image, $x1, $y1, $x2, $y2, $color); | |
Creates a rectangle in image filled with the color
color. The arguments x1
and y1 form the top left point of the rectangle
and x2 and y2 form the bottom
right.
imagefilltoborder($image, $x, $y, $border, $color); | |
Identical to imagefill except that the fill stops
where the color border is encountered.
imagegif($image, $filename);
Outputs the contents of image as a GIF image. If a
second argument is present the GIF is written to that filename,
otherwise the output is sent straight to the browser.
imageinterlace($image, $interlace); | |
Toggles the interlace bit of image to the value of
interlace, which should be 1 (for on) or
(for off).
imageline($image, $x1, $y1, $x2, $y2, $color); | |
Creates a line in image of color
color from the point (x1,
y2) to (x2,
y2).
imagepolygon($image, $points, $numpoints, $color); | |
Identical to imagefilledpolygon except that the
polygon is not filled.
imagerectangle($image, $x1, $y1, $x2, $y2, $color); | |
Identical to imagefilledrectangle except that the
rectangle is not filled.
imagesetpixel($image, $x, $y, $color); | |
Draws a single point on image at
(x, y) of color
color.
imagestring($image, $size, $x, $y, $string, $color); | |
Identical to imagechar except that it outputs the
entire string string.
imagestringup($image, $size, $x, $y, $string, $color); | |
Identical to imagecharup except that it outputs
the entire string string.
$x_size = imagesx($image); | |
Returns the width of image in pixels.
$y_size = imagesy($image); | |
Returns the height of image in pixels.
Includes the file filename in the current page.
Full PHP parsing is done on the included file. PHP searches each of
the directories in the environment variable
PHP_INCLUDE_PATH for filename.
Prepares the system for syslog logging. After
calling this function you can use syslog to
generate log entries.
$integer = intval($variable); | |
Returns the contents of variable as an integer.
$defined = isset($variable); | |
Returns 1 if variable is defined, 0 otherwise.
Returns the key of the next element in array. For
an associative array, it returns the name of the key. For a regular
array it returns the number of the element.
link($target, $filename); | |
Creates a hard link from filename to
target.
$info = linkinfo($filename); | |
Returns a true value if the link filename exists
(but not necessarily the file to which the link points). The function
returns -1 in case of an error.
Returns the natural logarithm of number.
$result = log10($number); | |
Returns the base 10 logarithm of number.
Logs the hit on the current page as a hit on
filename instead of the filename of the page.
mail($to, $subject, $message); | |
mail($to, $subject, $message, $headers);
Sends an e-mail message to to with the subject
subject and message as the
body, If a forth argument is provided it is appended to the headers
of the message.
Returns the largest value in array. If
array contains strings, it returns the element
that is last alphabetically.
Returns the MD5 hash of string.
Returns a string that contains the fractional part of the current
second (expressed as a decimal) followed by the standard Unix time.
Returns the minimum value in array. If array
contains strings, it returns the element that is first
alphabetically.
mkdir($directory, $mode); | |
Creates the directory directory with the given
mode. The mode must be an octal value.
$time = mktime($hour,$minute,$second,$month,$day,$year); | |
Returns a time in standard Unix time format based on the parameters
given. If there are less than six parameters, the rightmost
parameters are assumed to be the current value (e.g., if four
parameters are given, the current day and year are used).
$result = msql($database, $query);
$result = mysql($database, $query); | |
Sends the query query to the mSQL/MySQL database
database. For a non-SELECT
statement the function returns
for mSQL 1.x and MySQL and the number of affected rows for mSQL 2.x.
For a SELECT statement the function returns a
result identifier to be used with other msql_*
functions. In the case of an error the function returns -1.
$num_rows = mysql_affected_rows(); | |
Returns the number of rows affected by the last
INSERT, UPDATE, or
DELETE statement.
msql_close();
mysql_close(); | |
Closes the connection to the mSQL/MySQL database server.
msql_connect($hostname);
mysql_connect($hostname);
mysql_connect($hostname, $username);
mysql_connect($hostname, $username, $password); | |
Creates a connection with the mSQL/MySQL database server at
hostname. A connection to the server on the local
host is made with m(y)sql_connect("localhost"). If no
connection exists at the time of the first call to
m(y)sql, a connection is automatically made to the
localhost. With MySQL an optional username or username/password
combination may be given. If PHP is being run in its enhanced
security mode (called SAFE MODE), the username
must be either the owner of the HTML document or the owner of the web
server process.
msql_createdb($database);
mysql_createdb($database); | |
Creates the given database.
$db = msql_dbname($result, $i);
$db = mysql_dbname($result, $i); | |
Returns the name of the database stored in the ith
field of the result returned by a call to
m(y)sql_listdbs.
msql_dropdb($database);
mysql_dropdb($database); | |
Removes database and all tables within it.
$flags = msql_fieldflags($result, $i);
$flags = mysql_fieldflags($result, $i); | |
Returns the flags belonging to the ith field of
result. The returned value can be one of
"primary key", "not null", "not null
primary key" or "".
$length = msql_fieldlen($result, $i);
$length = mysql_fieldlen($result, $i); | |
Returns the length of the ith field of result.
$name = msql_fieldname($result, $i);
$name = mysql_fieldname($result, $i); | |
Returns the column name of the ith field of
result.
$type = msql_fieldtype($result, $i);
$type = mysql_fieldtype($result, $i); | |
Returns the type of the ith of
result (i.e. "char",
"real", etc.).
msql_freeresult($result);
mysql_freeresult($result); | |
Frees the memory associated with a mSQL/MySQL result. All memory is
automatically freed at the end of the script, so use this function
only if your script is taking up too much memory.
$id_num = mysql_insert_id(); | |
Returns the ID number used for the last INSERT statement that
contained an auto_increment field.
$result = msql_listdbs();
$result = mysql_listdbs(); | |
Returns a result pointer containing the names of all of the databases
available on the mSQL/MySQL server. The
m(y)sql_dbname function can retrieve values from
the pointer.
$result = msql_listfields($database, $table);
$result = mysqllistfields($database, $table); | |
Returns a result pointer to information about the fields of the table
table within database. The
functions m(y)sql_fieldflags,
m(y)sql_fieldlen,
m(y)sql_fieldname, and
m(y)sql_fieldtype can retrieve data from the
pointer.
$result = msql_listtables($database);
$result = mysql_listtables($database); | |
Returns a result pointer containing the names of all of the tables
within database. The
m(y)sql_tablename function can retrieves values
from the pointer.
$num_fields = msql_numfields($result);
$num_fields = mysql_numfields($result); | |
Returns the number of fields within result.
$num_rows = msql_numrows($result);
$num_rows = mysql_numrows($result);_ | |
Returns the number of rows within result.
$new_string = msql_regcase($string); | |
Returns a copy of string which has been
transformed into a regular expression that will perform a
case-insensitive match in a mSQL statement.
$result_string = msql_result($result, $i, $field);
$result_string = mysql_result($result, $I, $field); | |
Returns an entry from the field field in the
ith row of result. The argument
field is the name of the field column and can be
specified as table.field for results that involved
joined tables. Any MySQL internal functions which can affect SELECT
results can be included in the field argument, for
instance, mysql_result $result,
$i,"length($field)").
$name = msql_tablename($result, $i);
$name = mysql_tablename($result, $i); | |
Returns the name of the table stored in the ith
field of the result returned by a call to
m(y)sql_listtables.
next($array);
Moves the pointer of array to the next element and
returns that element.
$decimal = octdec($octal); | |
Returns the decimal equivalent of octal.
Opens a directory for use with the readdir
function. You should close the directory with
closedir when you are finished with it.
openlog($ident, $options, $facility); | |
Opens the system log for writing. This function should be called
after initlog and before the first
syslog call. The arguments are the same as the
Unix openlog system call. The value of ident is
prepended to each log message and is usually the name of the program.
The value of options can be any of the following:
LOG_CONS (log to the console if there is an error
with the standard procedure), LOG_NDELAY (open the
log connection immediately instead of at the time of the first log
message), LOG_PERROR (log to stderr as well),
LOG_PID (include the process PID with each log
message). Options can be combined with bitwise OR (e.g.
(LOG_DELAY|LOG_PERROR|LOG_PID)).
Facility is one of the system-defined log levels (e.g.
LOG_SYSLOG, LOG_USER,
LOG_KERN, etc.).
$number = ord($character); | |
Returns the ASCII value of character.
Parses a URL encoded string of the format
"variable1=value1&variable2=value2" and
initializes variables with the appropriate values. The PHP program
automatically performs this function with incoming form data at the
beginning of every script.
passthru($command);
passthru($command, $return_value); | |
Executes the external command command and sends
all of the output directory to the browser. If a second argument is
present, the return value of the command is placed there.
Closes a pipe opened with popen.
Prints an informational page that's useful when debugging the
PHP setup. This is the same page that is printed if you add
"?info" to any PHP URL, or if you access the PHP binary
directly (i.e., http://www.myserver.com/cgi-bin/php).
Returns the version of PHP that is currently running.
$fd = popen($command, $mode); | |
Runs the external command command and either sends
data to the command (if mode is "w")
or reads data from the command (if mode is
"r"). You must close any file descriptors opened in this
manner with pclose.
$position = pos($array['element']); | |
Returns the numerical position of
array['element']
within the associative array array.
Returns x raised to the power y.
Moves the internal pointer of array to the
previous element and returns that element.
Puts string into the local environment. Note that
the environment is destroyed at the end of the script, so this
function is really useful only when external programs are called
within the script.
$quoted_string = quotemeta($string); | |
Returns string with all special characters escaped
so that it is safe to use within a regular expression.
Returns a random number between
and the system-defined number RANDMAX. You should
seed the random number generator with srand once
and only once at the beginning of your script.
Returns the next directory entry in the current open directory and
advances the directory pointer. Repeated calls to this function will
return the next directory entry until there are no more left.
$filesize = readfile($filename); | |
Outputs the contents of filename directly to the
browser and returns the size of the file. This function is safe to
use on binary files such as images.
$filename = readline($link); | |
Returns the path of the real file referenced by
link. In case of error the function returns -1.
$result = reg_match($expression, $string);
$result = reg_match($expression, $string, $array); | |
Identical to ereg . This function is included
only for backwards compatibility with older versions of PHP.
reg_replace($expression, $replacement, $string); | |
Identical to ereg_replace . This function is
included only for backwards compatibility with older versions of PHP.
$partial_string = reg_search($expression, $string);
$partial_string = reg_search($expression, $string, $array); | |
Identical to ereg except that the portion of
string after the first match is returned. If there
is no match, the function returns an empty string. This function is
included only for backwards compatibility with older versions of PHP.
rename($oldfile, $newfile);
Renames oldfile to anewfile. | |
Moves the internal pointer of array to the first
element and returns that element.
Exits the current user-defined function and returns
value.
Moves the file pointer for fd to the beginning of
the file.
Moves the current directory pointer to the beginning of the directory.
Deletes directory if it is empty.
$sorted_array = rsort($array) | |
Returns a sorted copy of the nonassociative array
array in descending order. If the first member of
the array is a number, the returned array will be sorted numerically,
otherwise the returned array will be sorted alphabetically.
setcookie($name, $value, $expire, $path, $domain, $secure);
Sends a cookie with the given attributes to the browser. If only
name is present, that cookie with that name is
deleted from the browser. Any argument may be left out or replaced
with "" (or
in the case of expire and
secure) to be skipped.
seterrorreporting($value); | |
If value is 0, all errors will be disabled,
otherwise errors are reported as normal.
If value is nonzero, access logging for the
current page will be enabled, otherwise it will be disabled.
If value is nonzero, an informational footer will
be printed at the bottom of the page.
settype($variable, $type); | |
Sets the type of variable to
type, which can be integer,
double, or string.
$value = shl($number, $b); | |
Returns the value of number shifted
b bits to the left.
$value = shr($number, $b); | |
Returns the value of number shifted
b bits to the right.
Returns the sine of number (in radians).
Stops the processing of the page for seconds
seconds.
$sorted_array = sort($array) | |
Returns a sorted copy of the nonassociative array
array in ascending order. If the first member of
the array is a number, the returned array will be sorted numerically,
otherwise the returned array will be sorted alphabetically.
$soundex_key = soundex($string); | |
Returns the soundex key of string.
$string = sprintf($format, $arg, [$arg, $arg, ...]); | |
Returns format with each C printf-style variable
indicator replaced with the appropriate arg. Up to
5 arguments can be provided.
Returns the square root of number.
Seeds the random number generator with the value
integer. This function should be called once and
only once at the beginning of any script where you use the
rand function.
$substring = strchr($string, $value);
$substring = strstr($string, $value);
Returns the portion of string that occurs starting
after the first instance of value. The
strchr and strstr functions are
identical and are both included for the purposes of completeness.
strtr($string, $set1, $set2); | |
Translates all characters in string that are in
set1 to the corresponding character in
set2. If set1 is longer than
set2, the last character in
set2 is used for the extra characters in
set1. If set2 is longer than
set1, the extra characters in
set2 are ignored.
$plain_string = stripslashes($escaped_string); | |
Removes all escape characters from escaped_string.
$length = strlen($string); | |
Returns the length of string.
$substring = strrchr($string, $character); | |
Searches string backwards for character. The function returns the
portion of string from the first occurrence of
character it finds to the end of the string. An
empty string is returned if character is not
found.
$substring = strtok($string, $characters); | |
$substring = strtok($characters);
Splits string up into substrings using any of the
characters in characters as delimiters. After the
first call to strtok, omit the string argument in
subsequent calls to return each successive substring until the end of
string is reached.
$lc_string = strtolower($string); | |
Returns string with all characters converted to
lower case.
$uc_string = strtoupper($string); | |
Returns string with all characters converted to
upper case.
$string = strval($variable); | |
Returns variable as a string value.
$substring = substr($string, $start, $length); | |
Returns the portion of string that begins at
character start (0 is the first character) and
continues for length characters.
symlink($target, $filename); | |
Creates a symbolic link from filename to
target.
syslog($level, $message); | |
Logs message to the system logs at the level
level.
$results = system($command);
$results = system($command, $return_value); | |
Executes the external command command and returns
all output. If a second argument is provided, the return value of the
command is placed there.
Returns the tangent of number (in radians).
$filename = tempnam($path, $prefix); | |
Returns a filename, prepended with prefix, that
will be unique in the directory specified by path.
Returns the current time in Unix standard time format (the number of
seconds since Jan 1, 1970).
$umask = umask();
umask($umask); | |
Returns the current umask if no argument is specified. Sets the umask
to umask (which must be an octal number) if an
argument is present.
Returns a value that is guaranteed to be unique compared to other
values returned by repeated calls.
Deletes the specified file.
Undefines the specified variable, which may be an element of an
array. When performed on an array, it erases the entire array.
$decoded_string = urldecode($string); | |
Returns a copy of string that has all URL escape codes translated
into their values. This is done automatically with all incoming form
data.
$encoded_string = urlencode($string); | |
Returns a copy of string that has all special characters URL encoded.
Stops the parsing of the script for ms
microseconds.
Includes filename exactly as if the tag
<!--#include virtual="$filename"
--> were present in a standard HTML file. This function
is useful only in conjunction with the Apache web server.