Chapter 3. Function Library

This section describes the built-in subroutines in the Qore language making up the system function library. Following is a list of function categories, and below there is an alphabetically-ordered list of all Qore built-in functions.

Table 3.1. System Function Category List


Table 3.2. System Function Library

Function Name

Ret Type

Exception

Brief Description

abort()

N/A

N

aborts the process

abs()

Float or Integer

N

Returns the absolute value of the argument passed

acos()

Float

N

Returns the arc cosine of the number passed in radians

asin()

Float

N

Returns the arc sine of the number passed in radians.

atan()

Float

N

Returns the arc tangent of the number passed in radians.

backquote()

String

Y

Executes a process and returns a string of the output (stdout only)

basename()

String

N

Returns a string giving the last element of a file path.

binary()

Binary

N

Returns a binary data type of the data passed.

binary_to_string()

String

Y

Returns a string created from the binary data passed.

bindex()

Int

N

Returns the byte position of a substring within a string and takes an optional starting offset

blowfish_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for the blowfish algorithm.

blowfish_decrypt_cbc()

Binary

Y

Decrypts data using the Cipher Block Chaining function for the blowfish algorithm.

blowfish_decrypt_cbc_to_string()

String

Y

Decrypts data to a string using the Cipher Block Chaining function for the blowfish algorithm.

boolean()

Boolean

N

Converts the argument to a boolean value

brindex()

Int

N

Returns the byte position of a substring within a string as searched from the end of the string and takes an optional starting offset

call_builtin_function()

any

Y

Calls a builtin function identified by the first string argument and returns the return value, passing the remaining arguments after the function name to the function

call_builtin_function_args()

any

Y

Calls a builtin function identified by the first string argument and returns the return value, using the argument after the function name as a list of arguments to pass to the function.

call_function()

any

Y

Calls a function, closure, or call reference and returns the return value, passing the remaining arguments after the function name to the function (or call reference).

call_function_args()

any

Y

Calls a function, closure, or call reference and returns the return value, using the argument after the function name as a list of arguments to pass to the function, closure, or call reference.

callObjectMethod()

any

Y

calls a method given by a string of the object passed, passing the remaining arguments to the method as arguments

callObjectMethodArgs()

any

Y

calls a method given by a string of the object passed, using the argument after the method name as the list of arguments to pass to the method

cast5_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm.

cast5_decrypt_cbc()

Binary

Y

Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm.

cast5_decrypt_cbc_to_string()

String

Y

Decrypts data to a string using the Cipher Block Chaining function for the CAST5 algorithm.

cbrt()

Float

N

Returns the cube root of the number passed.

ceil()

Float

N

Returns a value rounded up to the next highest integer

chdir()

Integer

Y

Changes the current working directory.

chmod()

Integer

Y

Changes the mode of a file.

chomp()

String

N

Removes the trailing end-of-line indicator from a string and returns the new string (also see the chomp operator); also accepts variable references to do modifications in-place.

chown()

String

N

Changes the user and group owners of a file (if the current user has permission to do so), follows symbolic links.

chr()

String

N

Returns a string containing a single ASCII character represented by the numeric value passed.

clock_getmicros()

Integer

N

Returns the system time in microseconds (1/1000000 second intervals since Jan 1, 1970 00:00).

clock_getmillis()

Integer

N

Returns the system time in milliseconds (1/1000 second intervals since Jan 1, 1970 00:00).

clock_getnanos()

Integer

N

Returns the system time in nanoseconds (1/1000000000 second intervals since Jan 1, 1970 00:00).

compress()

Binary

Y

Performs zlib-based "deflate" data compression (RFC 1951) and returns a binary object of the compressed data.

convert_encoding()

String

Y

Performs explicit string character encoding conversions.

cos()

Float

N

Returns the cosine of the number in radians passed.

cosh()

Float

N

Returns the hyperbolic cosine of the number passed.

date()

Date

N

Converts the argument passed to a date.

date_ms()

Date

N

Converts an integer argument as a millisecond offset from January 1, 1970 to a date.

days()

Date

N

Returns a relative date in days for date arithmetic.

decode_url()

String

N

Decodes percent numeric codes in a URL string and returns the decoded string.

delete_all_thread_data()

n/a

N

Deletes all keys in the thread-local data hash.

delete_thread_data()

n/a

N

Deletes the data associated to one or more keys in the thread-local data hash (destroys any objects as well).

des_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for the DES algorithm.

des_decrypt_cbc()

Binary

Y

Decrypts data using the Cipher Block Chaining function for the DES algorithm.

des_decrypt_cbc_to_string()

String

Y

Decrypts data using the Cipher Block Chaining function for the DES algorithm.

des_ede_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm.

des_ede_decrypt_cbc()

Binary

Y

Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm.

des_ede_decrypt_cbc_to_string()

String

Y

Decrypts data to a string using the Cipher Block Chaining function for the two-key triple DES algorithm.

des_ede3_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm.

des_ede3_decrypt_cbc()

Binary

Y

Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm.

des_ede3_decrypt_cbc_to_string()

String

Y

Decrypts data to a string using the Cipher Block Chaining function for the three-key triple DES algorithm.

desx_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm.

desx_decrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm.

desx_decrypt_cbc_to_string()

String

Y

Encrypts data to a string using the Cipher Block Chaining function for RSA's DESX algorithm.

DSS()

String

Y

Returns the DSS message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

DSS_bin()

Binary

Y

Returns the DSS message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

DSS1()

String

Y

Returns the DSS1 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

DSS1_bin()

Binary

Y

Returns the DSS1 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

errno()

Integer

N

Returns the value of the system "errno" variable, holding the last error code generated by a system call

exec()

n/a

N

Replaces the current process image with another.

existsFunction()

Boolean

N

Returns True if the function exists in the current program's function name space.

exit()

N/A

N

Exits the program

exp()

Float

N

Returns the value of e raised to the power of the argument passed

exp2()

Float

N

Returns the value of 2 raised to the power of the argument passed

expm1()

Float

N

Returns an equivalent of exp(x) - 1

f_printf()

String

Y

"field" printf, field width specifiers are respected. Returns string printed.

f_sprintf()

String

Y

"field" sprintf(), field width specifiers are respected

float()

Float

N

Returns the argument converted to a floating-point number

floor()

Float

N

Returns a value rounded down to the nearest integer

flush()

n/a

N

Flushes output to the console output with print(), printf(), etc

force_encoding()

String

N

Returns a string tagged with the given character encoding; does not actually change the string data; use only in the case that a string is tagged with the wrong encoding.

fork()

Integer

N

Creates a duplicate of the current process

format_date()

String

N

Allows dates to be formatted

format_number()

String

N

Allows numbers to be formatted with more options than sprintf()

functionType()

String

N

Returns "builtin", "user", or NOTHING according to the function name passed

get_all_thread_data()

Hash

N

Returns the entire thread data hash.

get_days()

Integer

N

Returns an integer value representing the days value of the date passed (can be either a relative or absolute date).

get_default_encoding()

String

N

Returns the name of the default character encoding for the Qore library.

get_encoding()

String

N

Returns a string describing the character encoding of the string passed.

get_hours()

Integer

N

Returns an integer value representing the hours value of the date passed (can be either a relative or absolute date).

get_midnight()

Date

N

Returns a date/time value representing midnight on the date passed (strips the time from the date passed and returns the new value)

get_milliseconds()

Integer

N

Returns an integer value representing the milliseconds value of the date passed (can be either a relative or absolute date).

get_minutes()

Integer

N

Returns an integer value representing the minutes value of the date passed (can be either a relative or absolute date).

get_months()

Integer

N

Returns an integer value representing the months value of the date passed (can be either a relative or absolute date).

get_qore_library_info()

Hash

N

Returns a hash of build and version information for the qore library.

get_qore_option_list()

List

N

Returns a list of hashes giving information about qore library options.

get_seconds()

Integer

N

Returns an integer value representing the seconds value of the date passed (can be either a relative or absolute date).

get_script_path()

String

N

Returns a string giving the path (directory and filename) from which the current script was executed (if known).

get_script_dir()

String

N

Returns a string giving the directory from which the current script was executed (if known).

get_script_name()

String

N

Returns a string giving the filename of the current script (if known).

get_thread_data()

Any

N

Returns the value of the thread-local data attached to the key passed

get_years()

Integer

N

Returns an integer value representing the years value of the date passed (can be either a relative or absolute date).

getAllThreadCallStacks()

Hash

N

Returns a hash of call stacks keyed by each TID (thread ID).

getByte()

Integer

N

Returns the byte value withing the string or binary object passed.

getClassName()

String

N

Returns the class name of the object passed.

getcwd()

String

N

Returns the name of the current working directory.

getDateFromISOWeek()

Date

N

Retuns an absolute date value for the ISO-8601 calendar week information passed (year, week number, optional: day)

getDayOfWeek()

Integer

N

Returns an integer representing the day of the week for the absolute date passed (0=Sunday, 6=Saturday)

getDayNumber()

Integer

N

Returns an integer representing the ordinal day number in the year for the absolute date passed

getDBIDriverCapabilities()

Integer

N

Returns an integer representing the capabilities of a DBI driver.

getDBIDriverCapabilityList()

List

N

Returns a list of codes representing the capabilities of a DBI driver.

getDBIDriverList()

List

N

Returns a list of strings of DBI drivers currently available.

getegid()

Int

N

Returns the effective group ID of the current process.

geteuid()

Int

N

Returns the effective user ID of the current process.

getFeatureList()

List

N

Returns a list of strings of the builtin and module-supplied features of Qore.

getenv()

String

N

Retrieves the value of an environment variable

getgid()

Int

N

Returns the real group ID of the current process.

gethostbyaddr()

String

N

Returns the official hostname corresponding to the network addressed passed

gethostbyaddr_long()

Hash

N

Returns all host information corresponding to the network address

gethostbyname()

String

N

Returns the first network address corresponding to the hostname

gethostbyname_long()

Hash

N

Returns all host information corresponding to the hostname

gethostname()

String

N

Returns the hostname of the system

getISODayOfWeek()

Integer

N

Returns an integer representing the ISO-8601 day of the week for the absolute date passed (1=Monday, 7=Sunday)

getISOWeekHash()

Hash

N

Returns a hash representing the ISO-8601 calendar week information for the absolute date passed (hash keys: year, week, day)

getISOWeekString()

String

N

Returns a string representing the ISO-8601 calendar week information for the absolute date passed (ex: 2006-01-01 = "2005-W52-7")

getMethodList()

List

N

Returns a list of strings of the names of the methods of the class of the object passed as a parameter.

getModuleList()

List

N

Returns a list of hashes describing the currently-loaded Qore modules.

getpid()

Int

N

Returns the PID (process ID) of the current process.

getppid()

Int

N

Returns the parent PID of the current process.

getpwuid()

Hash

N

Returns a hash representing the user information of the user ID passed.

gettid()

Int

N

Returns the Qore thread ID (TID) of the current thread.

getuid()

Int

N

Returns the real user ID of the current process.

glob()

List

N

Returns a list of files matching the string argument

gmtime()

Date

N

Returns a date/time value in GMT

gunzip_to_binary()

Binary

N

Uncompresses data compressed with the "gzip" algorithm (RFC 1952) using zlib functions and returns a binary object.

gunzip_to_string()

String

N

Uncompresses data compressed with the "gzip" algorithm (RFC 1952) using zlib functions and returns a string.

gzip()

Binary

Y

Performs zlib-based "gzip" data compression (RFC 1952) and returns a binary object of the compressed data.

hash()

Hash

N

Converts an object or a list to a hash; otherwise returns an empty hash.

hash_values()

List

N

Returns a list of all the values in the hash argument passed.

hextoint()

Integer

N

Returns an integer for a hexadecimal string value.

hlstat()

Hash

N

Returns a hash of information about the file corresponding to the pathname argument; does not follow symbolic links (returns information about symbolic links).

hours()

Date

N

Returns a relative date in hours to be used in date arithmetic.

hstat()

Hash

N

Returns a hash of information about the file corresponding to the pathname argument; follows symbolic links.

html_decode()

String

Y

Returns a string with any HTML escape codes translated to the original characters

html_encode()

String

Y

Returns a string with any characters that can be escaped translated to HTML escape codes.

hypot()

Float

N

Returns the length of the hypotenuse of a right-angle triangle with sides given as the two arguments.

index()

Int

N

Returns the character position of a substring within a string and takes an optional starting offset

inlist()

Boolean

N

Returns True if the first argument is a member of the second argument list using comparisons with type conversions.

inlist_hard()

Boolean

N

Returns True if the first argument is a member of the second argument list using comparisons without type conversions.

int()

Int

N

Returns the argument converted to an integer

is_bdev()

Boolean

N

Returns True if the string passed identifies a block device file on the filesystem.

is_cdev()

Boolean

N

Returns True if the string passed identifies a character device file on the filesystem.

is_dev()

Boolean

N

Returns True if the string passed identifies a device file (either block or character) on the filesystem.

is_dir()

Boolean

N

Returns True if the string passed identifies a directory on the filesystem.

is_executable()

Boolean

N

Returns True if the string passed identifies an executable file.

is_file()

Boolean

N

Returns True if the string passed identifies a regular file on the filesystem.

is_link()

Boolean

N

Returns True if the string passed identifies a symbolic link on the filesystem.

is_pipe()

Boolean

N

Returns True if the string passed identifies a pipe (FIFO) on the filesystem.

is_readable()

Boolean

N

Returns True if the string passed identifies a file readable by the current user.

is_socket()

Boolean

N

Returns True if the string passed identifies a socket on the filesystem.

is_writeable()

Boolean

N

Returns True if the string passed identifies a file writable by the current user.

join()

String

N

Creates a string from a list and separator character

kill()

Int

N

Sends a signal to a process (default: SIGHUP)

lchown()

String

N

Changes the user and group owners of a file (if the current user has permission to do so), does not follow symbolic links.

length()

Int

N

Returns the length in characters for the string passed.

list()

List

N

Returns a list with the argument passed as the first element (or an empty list if no argument is passed)

load_module()

n/a

Y

Loads a Qore module at run-time if the feature name is not already present in the current Program object.

localtime()

Date

N

Returns a date value in localtime based on the value of the argument passed, which must be the number of seconds after Jan 1, 1970, 00:00:00

log10()

Float

N

Returns the base 10 logarithm of the value passed

log1p()

Float

N

Returns the natural logarithm of the value passed plus 1

logb()

Float

N

Returns the exponent of a number.

lstat()

List

N

Returns a list of filesystem values for the file or symbolic link passed.

makeBase64String()

String

N

Returns a base64-encoded representation of a binary object or a string.

makeFormattedJSONRPC11ErrorString()

String

Y

Creates a JSON-RPC 1.1 error response string from the parameters passed, formatted with line breaks for easier readability.

makeFormattedJSONRPCErrorString()

String

Y

Creates a generic JSON-RPC error response string from the parameters passed, formatted with line breaks for easier readability.

makeFormattedJSONRPCRequestString()

String

Y

Creates a JSON-RPC request string from the parameters passed, formatted with line breaks for easier readability.

makeFormattedJSONRPCResponseString()

String

Y

Creates a JSON-RPC response string from the parameters passed, formatted with line breaks for easier readability.

makeFormattedJSONString()

String

Y

Serializes qore data into a JSON string, formatted with line breaks for easier readability.

makeFormattedXMLFragment()

String

Y

Serializes a hash into an XML string with formatting and without an XML header.

makeFormattedXMLRPCCallString()

String

Y

Serializes the arguments into an XML string for an XML-RPC call with formatting.

makeFormattedXMLRPCCallStringWithEncoding()

String

Y

Serializes the arguments into an XML string for an XML-RPC call with formatting, taking an initial string argument to give the encoding for the created XML.

makeFormattedXMLRPCCallStringArgs()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC call with formatting, taking a single list argument for the argument list.

makeFormattedXMLRPCCallStringArgsWithEncoding()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC call with formatting, taking an initial string argument to give the encoding for the created XML, followed by the method name and a single list argument for the argument list.

makeFormattedXMLRPCFaultResponseString()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC fault response with whitespace formatting.

makeFormattedXMLRPCFaultResponseStringWithEncoding()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC fault response with whitespace formatting, taking an initial string argument to give the encoding for the created XML.

makeFormattedXMLRPCResponseString()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC response with whitespace formatting.

makeFormattedXMLRPCResponseStringWithEncoding()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC response with whitespace formatting, taking an initial string argument to give the encoding for the created XML.

makeFormattedXMLRPCValueString()

String

Y

Serializes the arguments into an XML string in XML-RPC Value format with whitespace formatting.

makeFormattedXMLString()

String

Y

Serializes a hash into an XML string with formatting and an XML header.

makeHexString()

String

N

Returns a hex-encoded representation of a binary object or a string.

makeJSONRPC11ErrorString()

String

Y

Creates a JSON-RPC 1.1 error response string from the parameters passed, without any line breaks.

makeJSONRPCErrorString()

String

Y

Creates a generic JSON-RPC error response string from the parameters passed, without any line breaks.

makeJSONRPCRequestString()

String

Y

Creates a JSON-RPC request string from the parameters passed, without any line breaks.

makeJSONRPCResponseString()

String

Y

Creates a JSON-RPC response string from the parameters passed, without any line breaks.

makeJSONString()

String

Y

Serializes qore data into a JSON string, without any line breaks.

makeXMLFragment()

String

Y

Serializes a hash into an XML string without an XML header or formatting.

makeXMLRPCCallString()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC call without formatting.

makeXMLRPCCallStringwithEncoding()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC call without formatting, taking an initial string argument to give the target character encoding for the XML string.

makeXMLRPCCallStringArgs()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC call without formatting, taking a single list argument for the argument list.

makeXMLRPCCallStringArgsWithEncoding()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC call without formatting, taking an initial string argument to give the target character encoding for the XML string followed by a list argument for the argument list.

makeXMLRPCFaultResponseString()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC fault response without formatting.

makeXMLRPCFaultResponseStringWithEncoding()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC fault response without formatting, taking an initial string argument to give the target character encoding for the XML string.

makeXMLRPCResponseString()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC response without formatting.

makeXMLRPCResponseStringWithEncoding()

String

Y

Serializes the arguments into an XML string formatted for an XML-RPC response without formatting, taking an initial string argument to give the target character encoding for the XML string.

makeXMLRPCValueString()

String

Y

Serializes the arguments into an XML string in XML-RPC Value format without formatting.

makeXMLString()

String

Y

Serializes a hash into a complete XML string with an XML header and without formatting.

max()

Any

N

Returns the maximum value in a list (see also min()); one variant takes an optional callback reference to process lists of complex data types.

MD2()

String

Y

Returns the MD2 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

MD2_bin()

Binary

Y

Returns the MD2 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

MD4()

String

Y

Returns the MD4 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

MD4_bin()

Binary

Y

Returns the MD4 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

MD5()

String

Y

Returns the MD5 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

MD5_bin()

Binary

Y

Returns the MD5 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

MDC2()

String

Y

Returns the MDC2 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

MDC2_bin()

Binary

Y

Returns the MDC2 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

milliseconds()

Date

N

Returns a relative date in milliseconds to be used in date arithmetic.

min()

Any

N

Returns the minumum value in a list (see also max()); one variant takes an optional closure or call reference to process lists of complex data types.

minutes()

Date

N

Returns a relative date in minutes to be used in date arithmetic.

mkdir()

Int

Y

Creates a directory.

mkfifo()

Int

N

Creates a named pipe

mktime()

Int

N

Returns the number of seconds after Jan 1, 1970, 00:00:00, assuming that the date passed is in local time

months()

Date

N

Returns a relative date in months to be used in date arithmetic.

nlog()

Float

N

Returns the natural logarithm of the value passed

now()

Date

N

Returns current date and time with resolution to the second

now_ms()

Date

N

Returns current date and time with resolution to the millisecond

num_threads()

Int

N

Returns the current number of threads in the process

ord()

Int

N

Gives the numeric value of the character passed

parse()

n/a

Y

Adds the text passed to the current program's code

parseBase64String()

Binary

Y

Parses a base64 encoded string and returns the binary object

parseDatasource()

Hash

N

Returns a hash of the components of a datasource string.

parseHexString()

Binary

Y

Parses a hex-encoded string and returns the binary object

parseJSON()

Qore Data

N

Parses a JSON string and returns the corresponding qore data structure.

parseURL()

Hash

Y

Parses a URL string and returns a hash of the components.

parseXML()

Hash

Y

parses an XML string and returns a Qore hash structure.

parseXMLWithRelaxNG()

Hash

Y

parses an XML string, validates the generated XML against a RelaxNG schema string, and returns a Qore hash structure.

parseXMLWithSchema()

Hash

Y

parses an XML string, validates the generated XML against an XSD schema string, and returns a Qore hash structure.

parseXMLAsData()

Hash

Y

parses an XML string as data (does not preserve hash order with out-of-order duplicate keys: collapses all to the same list) and returns a Qore hash structure.

parseXMLAsDataWithRelaxNG()

Hash

Y

parses an XML string as data (does not preserve hash order with out-of-order duplicate keys: collapses all to the same list), validates the generated XML against a RelaxNG schema string, and returns a Qore hash structure.

parseXMLAsDataWithSchema()

Hash

Y

parses an XML string as data (does not preserve hash order with out-of-order duplicate keys: collapses all to the same list), validates the generated XML against an XSD schema string, and returns a Qore hash structure.

parseXMLRPCCall()

Hash

Y

deserializies an XML-RPC call string, returning a Qore data structure representing the call information.

parseXMLRPCResponse()

Hash

Y

deserializies an XML-RPC response string, returning a Qore data structure representing the response information.

parseXMLRPCValue()

Hash

Y

deserializies an XML-RPC value tree, returning a Qore data structure representing the information.

pow()

Float

Y

Returns the value of the first argument raised to the power of the second

print()

-

Y

Prints the string passed without any formatting.

printf()

String

Y

Prints a formatted string and returns string printed.

rand()

Float

N

Returns a random integer number.

rc2_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm.

rc2_decrypt_cbc()

Binary

Y

Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm.

rc2_decrypt_cbc_to_string()

String

Y

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC2(tm) algorithm.

rc4_encrypt()

Binary

Y

Encrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm.

rc4_decrypt()

Binary

Y

Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm.

rc4_decrypt_to_string()

String

Y

Decrypts data to a string using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm.

rc5_encrypt_cbc()

Binary

Y

Encrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm.

rc5_decrypt_cbc()

Binary

Y

Decrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm.

rc5_decrypt_cbc_to_string()

String

Y

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC5(tm) algorithm.

regex()

Boolean

Y

Returns true if the regular expression matches the string passed

regex_extract()

String

Y

Returns a list of substrings in a string based on matching patterns defined by a regular expression.

regex_subst()

String

Y

Returns a string with patterns substituted according to the arguments passed.

remove_signal_handler()()

n/a

N

Removes an installed signal handler and returns the signal handling state to the default.

remove_thread_data()

n/a

N

Removes the listed keys from the thread-local data hash.

rename()

n/a

Y

Renames (or moves) a file or directory.

replace()

String

N

Replaces all occurrances of a substring in a string with another string and returns the new string.

reverse()

String or List

N

Reverses the order of a string or a list and returns the new string or list.

RIPEMD160()

String

Y

Returns the RIPEMD160 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

RIPEMD160_bin()

Binary

Y

Returns the RIPEMD160 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

rindex()

Int

N

Returns the starting character position of a string in another string as searched from the end of the string.

rmdir()

Int

Y

Removes a directory.

round()

Float

N

Returns a value rounded up to the nearest integer integer.

save_thread_data()

-

Y

Saves the data passed against the key passed in thread-local storage.

seconds()

Date

N

Returns a relative date/time value in seconds to be used in date arithmetic.

set_signal_handler()

n/a

N

Installs or replaces a signal handler.

setegid()

Integer

Y

Changes the process effective group ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

seteuid()

Integer

Y

Changes the process effective user ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

setenv()

String

N

Sets the value of an environment variable

setgid()

Integer

Y

Changes the process group ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

setuid()

Integer

Y

Changes the process user ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

SHA()

String

Y

Returns the SHA message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

SHA_bin()

Binary

Y

Returns the SHA message digest of the supplied argument as a binary object(for strings, the trailing null character is not included in the digest)

SHA1()

String

Y

Returns the SHA1 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

SHA1_bin()

Binary

Y

Returns the SHA1 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

SHA224()

String

Y

Returns the SHA224 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

SHA224_bin()

Binary

Y

Returns the SHA224 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

SHA256()

String

Y

Returns the SHA256 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

SHA256_bin()

Binary

Y

Returns the SHA256 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

SHA384()

String

Y

Returns the SHA384 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

SHA384_bin()

Binary

Y

Returns the SHA384 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

SHA512()

String

Y

Returns the SHA512 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

SHA512_bin()

Binary

Y

Returns the SHA512 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

sleep()

Int

N

Causes the current thread to sleep for a certain number of seconds.

sort()

List

Y

Sorts a list in ascending order (unstable); optionally takes a closure or a call reference (function or object method reference) to sort non-trivial data types.

sortDescending()

List

Y

Sorts a list in descending order (unstable); optionally takes a closure or call reference (function or object method reference) to sort non-trivial data types.

sortDescendingStable()

List

Y

Performs a descending stable sort on a list and returns the new list; optionally takes a closure or call reference (function or object method reference) to sort non-trivial data types.

sortStable()

List

Y

Performs an ascending stable sort on a list and returns the new list; optionally takes a closure or call reference (function or object method reference) to sort non-trivial data types.

split()

List

N

Splits a string into a list of components based on a separator string

sprintf()

String

Y

Creates a string from the format argument passed and the other arguments.

sin()

Float

N

Returns the sine of the number in radians passed.

sinh()

Float

N

Returns the hyperbolic sine of the number passed.

sqrt()

Float

N

Returns the square root of the number passed.

srand()

n/a

N

Seeds the random number generator with the integer passed.

stat()

List

N

Returns a list of filesystem information for the filename passed.

strerror()

String

N

Returns the description of the error number passed

string()

String

N

Returns the argument converted to a string

strlen()

Int

N

Returns the number of characters in a string

strtoint()

Integer

N

Returns an integer corresponding to the string passed with the possibility to specify the base (default base 10).

substr()

String

N

Returns a substring of a string

system()

Int

Y

Executes a process and returns the return code

tan()

Float

N

Returns the tangent of the number in radians passed.

tanh()

Float

N

Returns the hyperbolic tangent of the number passed.

thread_list()

List

N

Returns a list of all current thread IDs

throwThreadResourceExceptions()

n/a

Y

Immediately runs all thread resource cleanup routines for the current thread and throws all associated exceptions.

timegm()

Date

N

Returns the number of seconds since January 1, 1970 00:00 for a given date in GMT.

tolower()

String

N

Converts a string to all lowercase

toupper()

String

N

Converts a string to all uppercase

trim()

String

N

Removes the characters from a string (whiltespace by default, can be overridden) and returns the new string (also see the trim operator); also accepts variable references to do modifications in-place.

type()

Int

N

Returns the data type of the argument passed (see Type_Constants)

typename()

String

N

deprecated: use type() instead

umask()

Int

N

Sets the file creation mask for the process

uncompress_to_binary()

Binary

N

Uncompresses (inflates) data compressed with the "deflate" algorithm (RFC 1951) using zlib functions and returns a binary object.

uncompress_to_string()

String

N

Uncompresses (inflates) data compressed with the "deflate" algorithm (RFC 1951) using zlib functions and returns a string.

unlink()

Int

N

Deletes a file and returns 0 for success.

unsetenv()

n/a

N

Unsets an environment variable

usleep()

Int

N

Causes the current thread to sleep for a certain number of microseconds

vprintf()

String

Y

Outputs a formatted string based on a variable number of arguments given in a list after the format string. Returns the string printed.

vsprintf()

String

Y

Formats a string based on a variable number of arguments given in a list after the format string and returns this formatted string.

years()

Date

N

Returns a relative date/time value in years to be used in date arithmetic.


3.1. Math Functions

3.1.1. abs()

Synopsis

Returns the absolute value of the argument passed.

Usage
abs(numeric_expression)
Example
$x = abs($y);

Table 3.3. Arguments and Return Values for abs()

Argument Type

Return Type

Description

Integer

Integer

Absolute value of the integer passed.

Float

Float

Absolute value of the floating-point value passed.


This function does not throw any exceptions.

3.1.2. acos()

Synopsis

Returns the arc cosine of the number passed in radians

Usage
acos(float)
Example
$x = acos($y);

Table 3.4. Arguments and Return Values for acos()

Argument Type

Return Type

Description

Float

Float

Returns the arc cosine of the number passed in radians.


This function does not throw any exceptions.

3.1.3. asin()

Synopsis

Returns the arc sine of the number passed in radians

Usage
asin(float)
Example
$x = asin($y);

Table 3.5. Arguments and Return Values for asin()

Argument Type

Return Type

Description

Float

Float

Returns the arc sine of the number passed in radians.


This function does not throw any exceptions.

3.1.4. atan()

Synopsis

Returns the arc tangent of the number passed in radians

Usage
atan(float)
Example
$x = atan($y);

Table 3.6. Arguments and Return Values for atan()

Argument Type

Return Type

Description

Float

Float

Returns the arc tangent of the number passed in radians.


This function does not throw any exceptions.

3.1.5. cbrt()

Synopsis

Returns the cube root of the number passed.

Usage
cbrt(float)
Example
$x = cbrt($y);

Table 3.7. Arguments and Return Values for cbrt()

Argument Type

Return Type

Description

Float

Float

Returns the cube root of the number passed.


This function does not throw any exceptions.

3.1.6. ceil()

Synopsis

Returns a floating-point number equal to the smallest integral value greater than or equal to the argument passed.

Usage
ceil(float)
Example
$x = ceil(3.2); # will return 4.0 

Table 3.8. Arguments and Return Values for ceil()

Argument Type

Return Type

Description

Float

Float

Returns a value rounded up to the nearest integral floating-point value.


This function does not throw any exceptions.

3.1.7. cos()

Synopsis

Returns the cosine of the number in radians passed.

Usage
cos(float)
Example
$x = cos($y);

Table 3.9. Arguments and Return Values for cos()

Argument Type

Return Type

Description

Float

Float

Returns the cosine of the number in radians passed.


This function does not throw any exceptions.

3.1.8. cosh()

Synopsis

Returns the hyperbolic cosine of the number in radians passed.

Usage
cosh(float)
Example
$x = cosh($y);

Table 3.10. Arguments and Return Values for cosh()

Argument Type

Return Type

Description

Float

Float

Returns the hyperbolic cosine of the number in radians passed.


This function does not throw any exceptions.

3.1.9. exp()

Synopsis

Returns the value of e raised to the power of the argument passed.

Usage
exp(float)
Example
$x = exp($y);

Table 3.11. Arguments and Return Values for exp()

Argument Type

Return Type

Description

Float

Float

Returns the value of e raised to the power of the argument passed.


This function does not throw any exceptions.

3.1.10. exp2()

Synopsis

Returns the value of 2 raised to the power of the argument passed.

Usage
exp2(float)
Example
$x = exp2($y);

Table 3.12. Arguments and Return Values for exp2()

Argument Type

Return Type

Description

Float

Float

Returns the value of 2 raised to the power of the argument passed.


This function does not throw any exceptions.

3.1.11. expm1()

Synopsis

Returns an equivalent of exp(x) - 1.

Usage
expm1(float)
Example
$x = expm1($y);

Table 3.13. Arguments and Return Values for expm1()

Argument Type

Return Type

Description

Float

Float

Returns an equivalent of exp(x) - 1.


This function does not throw any exceptions.

3.1.12. floor()

Synopsis

Returns a floating-point value rounded down to the integral value.

Usage
floor(float)
Example
$x = floor(3.7); # will return 3.0

Table 3.14. Arguments and Return Values for floor()

Argument Type

Return Type

Description

Float

Float

Returns a float-point value rounded down to the integral value.


This function does not throw any exceptions.

3.1.13. format_number()

Synopsis

Returns a string of a formatted number according to the arguments passed.

Usage
format_number(format_string, number)
Description

The format_string has the following format: <thousands_separator>[<decimal_separator><decimals>], where thousands_separator and decimal_separator are single ASCII characters defining the thousands and decimal separator characters respectively, and decimals is a single digit defining how may decimals should appear after the decimal point.

Example
format_number(".,3", -48392093894.2349); # returns "-48.392.093.894,235"

Table 3.15. Arguments and Return Values for format_number()

Argument Types

Return Type

Description

String, Float

String

Returns a string corresponding to a number according to the formatting string passed.


This function does not throw any exceptions.

3.1.14. hypot()

Synopsis

Returns the length of the hypotenuse of a right-angle triangle with sides given as the two arguments.

Usage
hypot(float_x, float_y)
Example
$z = hypot($x, $y);

Table 3.16. Arguments and Return Values for hypot()

Argument Type

Return Type

Description

Float

Float

Returns the length of the hypotenuse of a right-angle triangle with sides given as the two arguments.


This function does not throw any exceptions.

3.1.15. log10()

Synopsis

Returns the base 10 logarithm of the value passed.

Usage
log10(float)
Example
$x = log10($y);

Table 3.17. Arguments and Return Values for log10()

Argument Type

Return Type

Description

Float

Float

Returns the base 10 logarithm of the value passed.


This function does not throw any exceptions.

3.1.16. log1p()

Synopsis

Returns the natural logarithm of the value passed plus 1.

Usage
log1p(float)
Example
$x = log1p($y);

Table 3.18. Arguments and Return Values for log1p()

Argument Type

Return Type

Description

Float

Float

Returns the natural logarithm of the value passed plus 1.


This function does not throw any exceptions.

3.1.17. logb()

Synopsis

Returns the exponent of a number.

Usage
logb(float)
Example
$x = logb($y);

Table 3.19. Arguments and Return Values for logb()

Argument Type

Return Type

Description

Float

Float

Returns the exponent of a number.


This function does not throw any exceptions.

3.1.18. nlog()

Synopsis

Returns the natural logarithm of the value passed.

Usage
nlog(float)
Example
$x = nlog();

Table 3.20. Arguments and Return Values for nlog()

Argument Type

Return Type

Description

Float

Float

Returns the natural logarithm of the value passed.


This function does not throw any exceptions.

3.1.19. pow()

Synopsis

Returns a number raised to the power of another number.

Usage
pow(x, y)
Example
$z = pow($x, $y);

Table 3.21. Arguments and Return Values for pow()

Argument Types

Return Type

Description

Float

Float

Returns x raised to the power of y.


Table 3.22. Exceptions Thrown by pow()

err

desc

DIVISION-BY-ZERO

pow(x, y): y must be a non-negative value.

INVALID-POW-ARGUMENTS

pow(x, y): x cannot be negative when y is not an integer value.


3.1.20. round()

Synopsis

Returns a floating-point number equal to the closest integer to the argument passed. Numers halfway between two integers are arounded away from zero. The availability of this function depends on the presence of the C-library's round() function; for maximum portability check the constant HAVE_ROUND before running this function. See Library Option Constants for a list of all option constants.

Usage
round(float)
Example
$x = round(3.2); # returns 3.0 

Table 3.23. Arguments and Return Values for round()

Argument Type

Return Type

Description

Float

Float

Returns a value rounded to the nearest integral floating-point value, half-way cases are rounded away from zero.


Table 3.24. Exceptions Thrown by round()

err

desc

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_ROUND before calling this function.


3.1.21. sin()

Synopsis

Returns the sine of the number in radians passed.

Usage
sin(float)
Example
$x = sin($y);

Table 3.25. Arguments and Return Values for sin()

Argument Type

Return Type

Description

Float

Float

Returns the sine of the number in radians passed.


This function does not throw any exceptions.

3.1.22. sinh()

Synopsis

Returns the hyperbolic sine of the number in radians passed.

Usage
sinh(float)
Example
$x = sinh($y);

Table 3.26. Arguments and Return Values for sinh()

Argument Type

Return Type

Description

Float

Float

Returns the hyperbolic sine of the number in radians passed.


This function does not throw any exceptions.

3.1.23. sqrt()

Synopsis

Returns the square root of the number passed.

Usage
sqrt(float)
Example
$x = sqrt($y);

Table 3.27. Arguments and Return Values for sqrt()

Argument Type

Return Type

Description

Float

Float

Returns the square root of the number passed.


This function does not throw any exceptions.

3.1.24. tan()

Synopsis

Returns the tangent of the number in radians passed.

Usage
tan(float)
Example
$x = tan($y);

Table 3.28. Arguments and Return Values for tan()

Argument Type

Return Type

Description

Float

Float

Returns the tangent of the number in radians passed.


This function does not throw any exceptions.

3.1.25. tanh()

Synopsis

Returns the hyperbolic tangent of the number in radians passed.

Usage
tanh(float)
Example
$x = tanh($y);

Table 3.29. Arguments and Return Values for tanh()

Argument Type

Return Type

Description

Float

Float

Returns the hyperbolic tangent of the number in radians passed.


This function does not throw any exceptions.