Executes a process and returns a string of the output (stdout only)
backquote(shell_command_string
)
$files = backquote("ls");
Not available with PO_NO_EXTERNAL_PROCESS
Table 3.307. Arguments and Return Values for backquote()
Argument Type | Return Type | Description |
---|---|---|
String | String | Executes the string passed as a shell command in a subprocess and returns the stdout of the process as a string. |
Table 3.308. Exceptions Thrown by backquote()
err | desc |
---|---|
| An error occurred with the |
Calls a builtin function and returns the return value, passing the remaining arguments after the function name to the builtin function. This function can be used to override a builtin function's functionality with a custom implementation.
call_builtin_function(func, [arg1, arg2, ...]
)
$result = call_builtin_function("func_name", $arg1, $arg2);
Table 3.309. Arguments and Return Values for call_builtin_function()
Argument Type | Return Type | Description |
---|---|---|
String, Any | Any (depends on function) | Executes the given builtin function with the remainder of the arguments as the arguments to the function. |
Table 3.310. Exceptions Thrown by call_builtin_function()
err | desc |
---|---|
| The first argument must be a string. |
| Parse options do not allow access to the function. |
| The function does not exist. |
Calls a builtin function and returns the return value, using the optional second argument as a list of arguments for the function.
call_builtin_function_args(func, [args]
)
call_builtin_function_args("func_name", $arg_list);
Table 3.311. Arguments and Return Values for call_builtin_function_args()
Argument Type | Return Type | Description |
---|---|---|
String, [List] | Any (depends on function) | Executes the given builtin function using any second argument as the list of arguments. |
Table 3.312. Exceptions Thrown by call_builtin_function_args()
err | desc |
---|---|
| The first argument must be a string. |
| Parse options do not allow access to the function. |
| The function does not exist. |
Calls a function, closure, or call reference and returns the return value, passing the remaining arguments after the function name to the function, closure, or call reference.
call_function(func, [arg1, arg2, ...]
)
$result = call_function("func_name", $arg1, $arg2);
$result = call_function($call_ref, $arg1, $arg2);
Table 3.313. Arguments and Return Values for call_function()
Argument Type | Return Type | Description |
---|---|---|
String | closure | call reference, Any | Any (depends on function) | Executes the given function, closure, or call reference with the remainder of the arguments as the arguments to the function, closure, or call reference to be called. |
Table 3.314. Exceptions Thrown by call_function()
err | desc |
---|---|
| The first argument must be a string, closure, or call reference. |
| Parse options do not allow access to the function. |
| The function does not exist. |
Calls a function, closure, or call reference and returns the return value, using the optional second argument as a list of arguments for the function, closure, or call reference to be called.
call_function_args(func, [args]
)
call_function_args("func_name", $arg_list);
call_function_args($call_ref, $arg_list);
Table 3.315. Arguments and Return Values for call_function_args()
Argument Type | Return Type | Description |
---|---|---|
String | closure | call reference, [List] | Any (depends on function) | Executes the given function, closure, or call reference using any second argument as the list of arguments. |
Table 3.316. Exceptions Thrown by call_function_args()
err | desc |
---|---|
| The first argument must be a string, closure, or call reference. |
| Parse options do not allow access to the function. |
| The function does not exist. |
Calls a method of an object, passing the remainder of the arguments to the function as arguments to the method.
callObjectMethod(object, method_string, [args ...]
)
$result = callObjectMethod($obj, "method", $arg1, $arg2);
Table 3.317. Arguments and Return Values for callObjectMethod()
Argument Type | Return Type | Description |
---|---|---|
Object, String, [args ...] | Any (depends on method) | Calls a method of an object, passing the remainder of the arguments to the function as arguments to the method, and returns the return value, if any. |
Table 3.318. Exceptions Thrown by callObjectMethod()
err | desc |
---|---|
| The named method does not exist in this class. |
| The named method may not be called explicitly. |
| The named method is private and therefore can only be called within the class. |
| The named method is a member of a privately inherited base class. |
Calls a method of an object, using the optional third argument as the argument list to the method.
callObjectMethodArgs(object, method_string, [arg_list]
)
$result = callObjectMethodArgs($obj, "method", $arg_list);
Table 3.319. Arguments and Return Values for callObjectMethodArgs()
Argument Type | Return Type | Description |
---|---|---|
Object, String, [args ...] | Any (depends on method) | Calls a method of an object, using the optional third argument as the argument list to the method, and returns the return value, if any. |
Table 3.320. Exceptions Thrown by callObjectMethodArgs()
err | desc |
---|---|
| The named method does not exist in this class. |
| The named method may not be called explicitly. |
| The named method is private and therefore can only be called within the class. |
| The named method is a member of a privately inherited base class. |
Returns True if the function exists in the current program's function name space.
existsFunction(string
)
$bool = existsFunction("func_name");
Table 3.321. Arguments and Return Values for existsFunction()
Argument Type | Return Type | Description |
---|---|---|
String | Boolean | Returns True if the function exists in the current program's function name space, otherwise returns False. |
This function does not throw any exceptions.
Returns "builtin", "user", or NOTHING according to the function name passed.
functionType(string
)
$type = functionType("print");
Table 3.322. Arguments and Return Values for functionType()
Argument Type | Return Type | Description |
---|---|---|
String | Boolean | Returns "builtin" (for a builtin function), "user" (for a user function), or NOTHING (if the function cannot be found) according to the function name passed. |
This function does not throw any exceptions.
Returns a hash of library build and version info with the keys in the table Library Info Hash. For constants giving the same information, see Build and Version Constants.
get_qore_library_info()
$info = get_qore_library_info();
Table 3.323. Arguments and Return Values for get_qore_library_info()
Arguments | Return Type | Description |
---|---|---|
n/a | Hash | A hash of library build and version info with the keys in the table Library Info Hash. For constants giving the same information, see Build and Version Constants. |
This function does not throw any exceptions.
Table 3.324. Library Info Hash
Key | Description |
---|---|
| The operating system used to build the Qore library. |
| The CPU used as a target for the Qore library build. |
| The full version string for this version of the Qore library. |
| An integer giving the Qore library's major version number. |
| An integer giving the Qore library's minor version number. |
| An integer giving the Qore library's release version number. |
| An integer giving the Qore library's subversion revision number. |
| A string giving information about the host used to compile the Qore library. |
| The compiler used to build the Qore library. |
| The module directory assumed by default in the Qore library. |
| The compiler flags used to compile the Qore library. |
| The linker flags used to link the Qore library. |
Returns a list of hashes giving information about Qore library options for the current build. See Library Option Hash for information about the elements in the list returned. See Library Options for information about Qore library options.
get_qore_option_list()
$list = get_qore_option_list();
Table 3.325. Arguments and Return Values for get_qore_option_list()
Arguments | Return Type | Description |
---|---|---|
n/a | List | A list of hashes giving information about Qore library options for the current build. See Library Option Hash for information about the elements in the list returned. |
Table 3.326. Library Option Hash
Key | Description |
---|---|
| The string description of the option |
| A string giving the name of the constant that has the boolean value for this option. |
| The type of option. |
| The boolean value of the option. |
This function does not throw any exceptions.
Returns the byte value of the offset (starting with 0) in the object passed. Of no offset is passed, then the value of the first byte (offset 0) is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.
getByte(expr, [offset]
)
$byte = getByte($bin, 2); # returns the thrid byte of the binary object
Table 3.327. Arguments and Return Values for getByte()
Arguments | Return Type | Description |
---|---|---|
| Integer | The value of the byte at the offset in the string or binary object. If no offset is passed, then the first byte is returned. If the object is empty or the offset is larger than the object's size, then no value is returned. |
Returns the class name of an object.
getClassName(object
)
$name = getClassName($obj);
Table 3.328. Arguments and Return Values for getClassName()
Argument Type |
Return Type |
Description |
---|---|---|
Object |
String |
Returns the class name of the object passed. |
This function does not throw any exceptions.
Returns an integer representing the capabilities of a DBI driver corresponding to the driver name passed as an argument. See SQL constants for constants for names of drivers shipping with the qore distribution.
getDBIDriverCapabilities(driver_name
)
$caps = getDBIDriverCapabilities("oracle");
Table 3.329. Arguments and Return Values for getDBIDriverCapabilities()
Argument Type | Return Type | Description |
---|---|---|
String | Integer | Returns an integer representing the capabilities of a DBI driver binary-OR'ed together (see DBI Capability Constants). Returns NOTHING if the driver cannot be found. |
This function does not throw any exceptions.
Returns a list of each capability supported by the given DBI driver. See SQL constants for constants giving names of drivers shipping with the Qore distribution.
getDBIDriverCapabilityList(driver_name
)
$list = getDBIDriverCapabilityList("mysql");
Table 3.330. Arguments and Return Values for getDBIDriverCapabilityList()
Argument Type | Return Type | Description |
---|---|---|
String | List | Returns a list of each capability supported by the given DBI driver (see DBI Capability Constants). Returns NOTHING if the driver cannot be found. |
This function does not throw any exceptions.
Returns a list of strings of DBI drivers currently loaded.
getDBIDriverList()
$list = getDBIDriverList();
Table 3.331. Arguments and Return Values for getDBIDriverList()
Argument Type | Return Type | Description |
---|---|---|
n/a | List | Returns a list of strings of DBI drivers currently loaded. |
This function does not throw any exceptions.
Returns a list of strings of the builtin and module-supplied features of Qore.
getFeatureList()
$list = getFeatureList();
Table 3.332. Arguments and Return Values for getFeatureList()
Argument Type | Return Type | Description |
---|---|---|
n/a | List | Returns a list of strings of the builtin and module-supplied features of Qore. |
This function does not throw any exceptions.
Returns a list of strings of the names of the methods of the class of the object passed as a parameter.
getMethodList(object
)
$list = getMethodList($obj);
Table 3.333. Arguments and Return Values for getMethodList()
Argument Type | Return Type | Description |
---|---|---|
Object | List | Returns all methods in the class, both private and public. Does not return inherited methods. If no object is passed to the function, NOTHING is returned. |
This function does not throw any exceptions.
Returns a list of hashes describing the currently-loaded Qore modules.
getModuleList()
$list = getModuleList();
Table 3.334. Arguments and Return Values for getModuleList()
Argument Type | Return Type | Description |
---|---|---|
n/a | List | Each element in the list is a hash describing currently-loaded qore modules. |
This function does not throw any exceptions.
Returns the name of the default character encoding for the currently-running Qore process.
get_default_encoding()
$encoding = get_default_encoding();
Table 3.335. Arguments and Return Values for get_default_encoding()
Argument Type | Return Type | Description |
---|---|---|
n/a | String | Returns the name of the default character encoding. |
This function does not throw any exceptions.
Returns a hash representing the user information for the user ID passed.
getpwuid(integer_uid
)
$hash = getpwuid(0); # returns the login information for root
Table 3.336. Arguments and Return Values for getpwuid()
Argument Type |
Return Type |
Description |
---|---|---|
Integer |
Hash |
Returns a hash representing the user information for the user ID passed. If the uid does not exist, NOTHING is returned. Otherwise the hash has the following keys: pw_name, pw_passwd, pw_gecos, pw_dir, pw_shell, pw_uid, pw_gid. |
This function does not throw any exceptions.
Returns the path (directory and filename) of the current script. Returns NOTHING if unknown (i.e. no parent script, script read from stdin, etc).
get_script_path()
$path = get_script_path();
Table 3.337. Arguments and Return Values for get_script_path()
Argument Type | Return Type | Description |
---|---|---|
n/a | String or NOTHING | Returns the path name of the current script, or NOTHING if unknown. |
This function does not throw any exceptions.
Returns the name of the directory from which the current script was executed. Returns NOTHING if the parent script is unknown (i.e. no parent script, script read from stdin, etc).
get_script_dir()
$dir = get_script_dir();
Table 3.338. Arguments and Return Values for get_script_dir()
Argument Type | Return Type | Description |
---|---|---|
n/a | String or NOTHING | Returns the name of the directory for the current script, or NOTHING if unknown. |
This function does not throw any exceptions.
Returns the filename of the current script if known; returns NOTHING if not (i.e. no parent script, script read from stdin, etc).
get_script_name()
$name = get_script_name();
Table 3.339. Arguments and Return Values for get_script_name()
Argument Type | Return Type | Description |
---|---|---|
n/a | String or NOTHING | Returns the filename of the current script, or NOTHING if unknown. |
This function does not throw any exceptions.
Returns a list of all the values in the hash argument passed.
hash_values(hash
)
$list = hash_values($hash);
Table 3.340. Arguments and Return Values for hash_values()
Argument Type |
Return Type |
Description |
---|---|---|
Hash |
List |
Returns a list of all the values in the hash argument passed. If no hash is passed, returns NOTHING. |
This function does not throw any exceptions.
Returns an integer for a hexadecimal string value.
hextoint(hex_string
)
$int = hextoint("ab3d4e0f12");
Table 3.341. Arguments and Return Values for hextoint()
Argument Type |
Return Type |
Description |
---|---|---|
String |
Integer |
Returns an integer for a hexadecimal string value. |
This function does not throw any exceptions.
Returns a string with any HTML escape codes translated to the original characters.
html_decode(string
)
html_decode("<hello>"); # returns "<hello>"
Table 3.342. Arguments and Return Values for html_decode()
Argument Type | Return Type | Description |
---|---|---|
String | String | Returns a string with any HTML escape codes (ie & -> &, etc) translated to the original characters. |
This function does not throw any exceptions.
Returns a string with any characters that can be escaped translated to HTML escape codes.
html_encode(string
)
$str = html_encode("<hello>"); # returns "<hello>"
Table 3.343. Arguments and Return Values for html_encode()
Argument Type | Return Type | Description |
---|---|---|
String | String | Returns a string with characters needed HTML escape code transation (ie & -> & etc) translated to the escape codes. |
This function does not throw any exceptions.
Tests if the first argument is a member of the second argument list; types are converted if necessary. If the second argument is NOTHING, then False is returned unconditionally (i.e. even if the first argument is NOTHING as well), however if the second argument is not a list then the return value of the function is the comparison of the two arguments. For a version of this function that requires types to be equal for the comparison to succeed, see inlist_hard().
inlist(value, list
)
my $bool = inlist(123, (True, "123", False); # this will return True
Table 3.344. Arguments and Return Values for inlist()
Argument Type | Return Type | Description |
---|---|---|
| Boolean | Returns True if |
| Boolean | Always returns False. |
| Boolean | Returns the value of the comparison of |
This function does not throw any exceptions.
Tests if the first argument is a member of the second argument list; no type conversions are performed (i.e. the comparison fails if types are not equal). If the second argument is NOTHING, then False is returned unconditionally (i.e. even if the first argument is NOTHING as well), however if the second argument is not a list then the return value of the function is the comparison of the two arguments (types must be equal). For a "soft" version of this function that performs type conversions when doing the comparison, see inlist().
inlist_hard(value, list
)
my $bool = inlist_hard(123, (True, "123", False); # this will return False
Table 3.345. Arguments and Return Values for inlist_hard()
Argument Type | Return Type | Description |
---|---|---|
| Boolean | Returns True if |
| Boolean | Always returns False. |
| Boolean | Returns the value of the comparison of |
This function does not throw any exceptions.
Loads in a Qore module at run-time. If a feature with the same name already exists, then this feature's code is imported into the current Program object if necessary and no further action is taken. Note that modules providing objects resolved at parse time (classes, constants, functions, etc) must be loaded with the %requires
directive instead, unless all references to the objects provided by the module will be made in code embedded in Program objects.
See also getFeatureList() for a function providing a list of available features.
load_module(module_name
)
load_module("pgsql");
Table 3.346. Arguments and Return Values for load_module()
Argument Type | Return Type | Description |
---|---|---|
String | String | Loads the module with the given name if possible, otherwise throws an exception. This function returns no value. |
Table 3.347. Exceptions Thrown by load_module()
err | desc |
---|---|
| An error occurred loading the module (module not found, libraries not resolved, wrong module API, etc). |
Returns a base64-encoded representation of a binary object or a string (see also makeHexString()).
makeBase64String(arg
)
$str = makeBase64String($bin);
Table 3.348. Arguments and Return Values for makeBase64String()
Argument Type | Return Type | Description |
---|---|---|
Binary or String | String | Returns a base64-encoded representation of a binary object or a string. |
This function does not throw any exceptions.
Returns a hex-encoded representation of a binary object or a string (see also makeBase64String()).
makeHexString(arg
)
$str = makeHexString($bin);
Table 3.349. Arguments and Return Values for makeHexString()
Argument Type | Return Type | Description |
---|---|---|
Binary or String | String | Returns a hex-encoded representation of a binary object or a string. |
This function does not throw any exceptions.
Returns the maximum value in a list (see also min()). Without a callback, this function will only work on basic data types. A closure or call reference can be used to find the maximum value of a list of complex data types. The closure or call reference must accept two arguments and must return -1, 0, or 1 if the first is less than, equal to, or greater than the second, respectively.
max(list, [callback]
)
max(elem1, elem2[, ...]
)
$max = max($complex_list, \callback_function());
$max = max(1, 2, 3, 4);
Table 3.350. Arguments and Return Values for max()
Argument Type | Return Type | Description |
---|---|---|
| Any | Finds the maxmimum value in the list and returns that value. The list must be made up of basic data types unless a closure or call reference is used as described above. |
| Any | Finds the maximum value in the list of simple data types passed as top-level arguments to the function and returns that value. No callback reference can be specified with this variant. |
This function does not throw any exceptions (note a closure or call reference could throw an exception).
Returns the minumum value in a list (see also max()). Without a callback, this function will only work on basic data types. A closure or call reference can be used to find the minimum value of a list of complex data types. The closure or call reference must accept two arguments and must return -1, 0, or 1 if the first is less than, equal to, or greater than the second, respectively.
min(list, [callback]
)
min(elem1, elem2[, ...]
)
$min = min($complex_list, \callback_function());
$min = min(1, 10, 2, 3);
Table 3.351. Arguments and Return Values for min()
Argument Type | Return Type | Description |
---|---|---|
| Any | Finds the minimum value in the list and returns that value. The list must be made up of basic data types unless a closure or call reference is used as described above. |
| Any | Finds the minimum value in the list of simple data types passed as top-level arguments to the function and returns that value. No closure or call reference can be specified with this variant. |
This function does not throw any exceptions (note that a closure or call reference could throw an exception).
Adds the text passed to the current program's code.
parse(code_string, label_string
)
parse($code, "label");
Table 3.352. Arguments and Return Values for parse()
Argument Type | Return Type | Description |
---|---|---|
String | n/a | Parses the string passed and adds the code to the current program. |
Parses a base64 encoded string and returns the binary object (see also parseHexString()).
parseBase64String(base64_string
)
$bin = parseBase64String($base64_string);
Table 3.354. Arguments and Return Values for parseBase64String()
Argument Type | Return Type | Description |
---|---|---|
String | Binary | Parses a base64 encoded string and returns the binary object. If anything is passed other than a string as an argument, no action is taken and the function returns NOTHING. |
Table 3.355. Exceptions Thrown by parseBase64String()
err | desc |
---|---|
| A syntax error occurred parsing the base64 string (invalid character, etc). |
Returns a hash of the components of a datasource string.
parseDatasource(datasource_string
)
$hash = parseDatasource($ds_string);
Table 3.356. Arguments and Return Values for parseDatasource()
Argument Type | Return Type | Description |
---|---|---|
String | Hash | Returns a hash of the components of a datasource string. A datasource string has the following structure: |
Table 3.357. Exceptions Thrown by parseDatasource()
err | desc |
---|---|
| A syntax error occurred parsing the datasource string (missing field, unexpected character, etc). |
Table 3.358. parseDatasource() hash
Key | Description |
---|---|
| the name of the driver, if present |
| the username given in the string |
| the password for the connection |
| the database name for the connection |
| The name of the DB-specific character encoding to use for the connection, if present in the string |
| the hostname for the connection, if present in the string |
| the port number to use for the connection, if present in the string |
Parses a hex-encoded string and returns the binary object (see also parseBase64String()).
parseHexString(hex_string
)
$bin = parseHexString($hex_string);
Table 3.359. Arguments and Return Values for parseHexString()
Argument Type | Return Type | Description |
---|---|---|
String | Binary | Parses a hex-encoded string and returns the binary object. If anything is passed other than a string as an argument, no action is taken and the function returns NOTHING. |
Table 3.360. Exceptions Thrown by parseHexString()
err | desc |
---|---|
| A syntax error occurred parsing the hex string (odd number of digits, invalid character, etc). |
Parses a URL string and returns a hash of the components with the following keys (if data in the URL is present): protocol, path, username, password, host, port
parseURL(url_string
)
$hash = parseURL($url_string);
Table 3.361. Arguments and Return Values for parseURL()
Argument Type | Return Type | Description |
---|---|---|
String | Hash | Parses a URL string and returns a hash of the components. URLs have the format: |
This function does not throw any exceptions.
Returns a random integer number (uses the C library function random()
to generate the number).
rand()
$num = rand();
Table 3.362. Arguments and Return Values for rand()
Argument Type | Return Type | Description |
---|---|---|
n/a | Integer | A random integer number is returned. See srand() for a function to seed the random number generator. |
This function does not throw any exceptions.
Removes a signal handler and returns the signal handling state to the default. By the time this function returns, changes to the signal handling thread have already been effected. See Signal Handling for more information.
remove_signal_handler(signal
)
remove_signal_handler(SIGINT);
Not available with PO_NO_PROCESS_CONTROL
Table 3.363. Arguments and Return Values for remove_signal_handler()
Argument Type | Return Type | Description |
---|---|---|
Integer | n/a | The signal number to process. |
This function does not throw any exceptions.
Reverses a string or a list (depending on the argument) and returns the new string or list. Works properly on UTF-8 strings with multi-byte characters as well.
reverse(string_or_list
)
$str = reverse("ABCDEF"); # returns "FEDCBA"
Table 3.364. Arguments and Return Values for reverse()
Argument Type | Return Type | Description |
---|---|---|
List | List | The list with its elements reversed. |
String | String | The string with its characters reversed. |
This function does not throw any exceptions.
Sets or replaces a signal handler according to the signal number and closure or call reference (function or object method reference) passed. By the time this function returns, changes to the signal handling thread have already been effected. See Signal Handling for more information.
When a signal is raised and the signal handler code is called, the signal number is passed as an integer argument to the signal handling code.
set_signal_handler(signal, closure | call_reference
)
set_signal_handler(SIGINT, \signal_handler());
Not available with PO_NO_PROCESS_CONTROL
Table 3.365. Arguments and Return Values for set_signal_handler()
Argument Type | Return Type | Description |
---|---|---|
Integer, closure | Call Reference | n/a | The signal number to process and reference to the code to execute when the signal is raised. |
This function does not throw any exceptions.
Performs an unstable sort in ascending order and returns the new list (for a stable version see sortStable()). Without a callback, this function will only sort basic data types. A closure or call reference can be used to sort complex data types. The closure or call reference must accept two arguments and must return -1, 0, or 1 if the first is less than the second, if the first and second are equal, or if the first is greater than the second, respectively.
sort(list, [callback]
)
$list = sort($complex_list, \callback());
Table 3.366. Arguments and Return Values for sort()
Argument Type | Return Type | Description |
---|---|---|
List, [closure | Call Reference] | List | Sorts the list passed in ascending order and returns the sorted list. The list must be made up of basic data types unless a closure or call reference is used. |
This function does not throw any exceptions.
Performs an unstable sort in descending order and returns the new list (for a stable version see sortDescendingStable()). Without a closure or call reference, this function will only sort basic data types. A closure or call reference can be used to sort complex data types. The closure or call reference must accept two arguments and must return -1, 0, or 1 if the first is less than the second, if the first and second are equal, or if the first is greater than the second, respectively.
sortDescending(list, [callback]
)
$list = sortDescending($complex_list, \callback());
Table 3.367. Arguments and Return Values for sortDescending()
Argument Type | Return Type | Description |
---|---|---|
List, [closure | Call Reference] | List | Sorts the list passed in descending order and returns the sorted list. The list must be made up of basic data types unless a closure or call reference is used. |
This function does not throw any exceptions.
Performs a stable sort in descending order and returns the new list (for an unstable version see sortDescending()). Without a closure or call reference, this function will only sort basic data types. A closure or call reference can be used to sort complex data types. The closure or call reference must accept two arguments and must return -1, 0, or 1 if the first is less than the second, if the first and second are equal, or if the first is greater than the second, respectively.
sortDescendingStable(list, [callback]
)
$list = sortDescendingStable($complex_list, \callback());
Table 3.368. Arguments and Return Values for sortDescendingStable()
Argument Type | Return Type | Description |
---|---|---|
List, [closure | Call Reference] | List | Sorts the list passed in descending order and returns the sorted list. The list must be made up of basic data types unless a closure or call reference is used. |
This function does not throw any exceptions.
Performs a stable sort in ascending order and returns the new list (for an unstable version see sort()). Without a closure or call reference, this function will only sort basic data types. A closure or call reference can be used to sort complex data types. The closure or call reference must accept two arguments and must return -1, 0, or 1 if the first is less than the second, if the first and second are equal, or if the first is greater than the second, respectively.
sortStable(list, [callback]
)
$list = sortStable($complex_list, \callback());
Table 3.369. Arguments and Return Values for sortStable()
Argument Type | Return Type | Description |
---|---|---|
List, [closure | Call Reference] | List | Sorts the list passed in ascending order and returns the sorted list. The list must be made up of basic data types unless a closure or call reference is used. |
This function does not throw any exceptions.
Seeds the random number generator with the integer passed (uses the C library function srandom()
).
srand(integer
)
srand(now()); # seeds with current time
Table 3.370. Arguments and Return Values for srand()
Argument Type | Return Type | Description |
---|---|---|
Integer | n/a | Seeds the random number generator with the integer passed. See rand() for a function to get a random number. |
This function does not throw any exceptions.
Returns an integer corresponding to the string passed with the possibility to specify the base (default base 10).
strtoint(string, [base]
)
$int = strtoint("41", 8);
Table 3.371. Arguments and Return Values for strtoint()
Argument Type |
Return Type |
Description |
---|---|---|
String |
Integer |
Returns an integer corresponding to the string value in the base specified. If no base is passed, then base 10 is assumed. |
This function does not throw any exceptions.