3.12. Miscellaneous Functions

3.12.1. backquote()

Synopsis

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

Prototype

string backquote(string $cmd)

nothing backquote() (RT_NOOP)

Example
$files = backquote("ls");
Restrictions

Not available with PO_NO_EXTERNAL_PROCESS

Table 3.346. Arguments and Return Values for backquote()

Argument Type

Return Type

Description

string $cmd

string

Executes the string passed as a shell command in a subprocess and returns the stdout of the process as a string.


Table 3.347. Exceptions Thrown by backquote()

err

desc

BACKQUOTE-ERROR

An error occurred with the fork() or opening the stdout pipe.


3.12.2. call_builtin_function()

Synopsis

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.

Prototype

any call_builtin_function(string $name, ...)

Example
$result = call_builtin_function("func_name", $arg1, $arg2);

Table 3.348. Arguments and Return Values for call_builtin_function()

Argument Type

Return Type

Description

string $name, ...

any

Executes the given builtin function with the remainder of the arguments as the arguments to the function.


Table 3.349. Exceptions Thrown by call_builtin_function()

err

desc

INVALID-FUNCTION-ACCESS

Parse options do not allow access to the function.

NO-FUNCTION

The builtin function does not exist.


3.12.3. call_builtin_function_args()

Synopsis

Calls a builtin function and returns the return value, using the optional second argument as a list of arguments for the function.

Prototype

any call_builtin_function_args(string $name, list $args)

any call_builtin_function_args(string $name, any $arg)

Example
call_builtin_function_args("func_name", $arg_list);

Table 3.350. Arguments and Return Values for call_builtin_function_args()

Argument Type

Return Type

Description

string $name, list or any $args

any

Executes the given builtin function using any second argument as the list of arguments; if the second argument is not a list it will be created as a list with one element.


Table 3.351. Exceptions Thrown by call_builtin_function_args()

err

desc

INVALID-FUNCTION-ACCESS

Parse options do not allow access to the function.

NO-FUNCTION

The builtin function does not exist.


3.12.4. call_function()

Synopsis

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.

Prototype

any call_function(string $name, ...)

any call_function(code $code, ...)

Example
$result = call_function("func_name", $arg1, $arg2);
$result = call_function($call_ref, $arg1, $arg2);

Table 3.352. Arguments and Return Values for call_function()

Argument Type

Return Type

Description

string $name or code $code, ...

any

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.353. Exceptions Thrown by call_function()

err

desc

INVALID-FUNCTION-ACCESS

Parse options do not allow access to the function.

NO-FUNCTION

The function does not exist.


3.12.5. call_function_args()

Synopsis

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.

Prototype

any call_function_args(string $name, list $args)

any call_function_args(string $name, any $arg)

any call_function_args(code $code, list $args)

any call_function_args(code $code, any $arg)

Example
call_function_args("func_name", $arg_list);
call_function_args($call_ref, $arg_list);

Table 3.354. Arguments and Return Values for call_function_args()

Argument Type

Return Type

Description

string $name or code $code, list or any $args

any

Executes the given function, closure, or call reference using any second argument as the list of arguments.


Table 3.355. Exceptions Thrown by call_function_args()

err

desc

INVALID-FUNCTION-ACCESS

Parse options do not allow access to the function.

NO-FUNCTION

The function does not exist.


3.12.6. callObjectMethod()

Synopsis

Calls a method of an object, passing the remainder of the arguments to the function as arguments to the method.

Prototype

any callObjectMethod(object $obj, string $method, ...)

nothing callObjectMethod() (RT_NOOP)

Example
$result = callObjectMethod($obj, "method", $arg1, $arg2);

Table 3.356. Arguments and Return Values for callObjectMethod()

Argument Type

Return Type

Description

object $obj, string $method, ...

any

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.357. Exceptions Thrown by callObjectMethod()

err

desc

METHOD-DOES-NOT-EXIST

The named method does not exist in this class.

ILLEGAL-EXPLICIT-METHOD-CALL

The named method may not be called explicitly.

METHOD-IS-PRIVATE

The named method is private and therefore can only be called within the class.

BASE-CLASS-IS-PRIVATE

The named method is a member of a privately inherited base class.


3.12.7. callObjectMethodArgs()

Synopsis

Calls a method of an object, using the optional third argument as the argument list to the method.

Prototype

any callObjectMethodArgs(object $obj, string $method, list $args)

any callObjectMethodArgs(object $obj, string $method, any $arg)

nothing callObjectMethodArgs() (RT_NOOP)

Example
$result = callObjectMethodArgs($obj, "method", $arg_list);

Table 3.358. Arguments and Return Values for callObjectMethodArgs()

Argument Type

Return Type

Description

object $obj, string $method, list or any $args

any

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.359. Exceptions Thrown by callObjectMethodArgs()

err

desc

METHOD-DOES-NOT-EXIST

The named method does not exist in this class.

ILLEGAL-EXPLICIT-METHOD-CALL

The named method may not be called explicitly.

METHOD-IS-PRIVATE

The named method is private and therefore can only be called within the class.

BASE-CLASS-IS-PRIVATE

The named method is a member of a privately inherited base class.


3.12.8. existsFunction()

Synopsis

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

Prototype

bool existsFunction(string $name) (CONST)

bool existsFunction(code $code) (NOOP)

nothing existsFunction() (RT_NOOP)

Example
$bool = existsFunction("func_name");

Table 3.360. Arguments and Return Values for existsFunction()

Argument Type

Return Type

Description

string $name

bool

Returns True if the function exists in the current program's function name space, otherwise returns False.

code $code

bool

This version always returns True.


This function does not throw any exceptions.

3.12.9. functionType()

Synopsis

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

Prototype

*string functionType(string) (CONST)

nothing functionType() (RT_NOOP)

Example
my *string $type = functionType("print");

Table 3.361. Arguments and Return Values for functionType()

Argument Type

Return Type

Description

string

*string

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.

3.12.10. get_byte()

Synopsis

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.

Note that this function is identical to getByte() except that this version has no RT_NOOP variant.

Prototype

*int get_byte(data $data, softint $offset $offset = 0) (CONST)

Example
my *int $byte = get_byte($bin, 2); # returns the third byte of the binary object

Table 3.362. Arguments and Return Values for get_byte()

Arguments

Return Type

Description

data $data, softint $offset $offset = 0)

*int

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.


3.12.11. get_word_16()

Synopsis

Returns the 16-bit integer value at the 2-byte offset (starting with 0) in the data passed. Of no offset is passed, then the value of the first 16-bit position at offset 0 is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.

This function assumes MSB byte order when retrieving the value from the data.

See also get_word_16_lsb().

Prototype

*int get_word_16(data $data, softint $offset = 0) (CONST)

Example
my *int $val = get_word_16($bin, 2); # returns the third 16-bit value in MSB format of the binary object

Table 3.363. Arguments and Return Values for get_word_16()

Arguments

Return Type

Description

data $data, softint $offset = 0)

*int

The MSB integer value of the data at the 2-byte offset given in the string or binary object. If no offset is passed, then the first 16-bit value is returned. If the object is empty or the offset is larger than the object's size, then no value is returned.


3.12.12. get_word_16_lsb()

Synopsis

Returns the 16-bit integer value at the 2-byte offset (starting with 0) in the data passed. Of no offset is passed, then the value of the first 16-bit position at offset 0 is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.

This function assumes LSB byte order when retrieving the value from the data.

See also get_word_16().

Prototype

*int get_word_16_lsb(data $data, softint $offset = 0) (CONST)

Example
my *int $val = get_word_16_lsb($bin, 2); # returns the third 16-bit value in LSB format of the binary object

Table 3.364. Arguments and Return Values for get_word_16_lsb()

Arguments

Return Type

Description

data $data, softint $offset = 0)

*int

The LSB integer value of the data at the 2-byte offset given in the string or binary object. If no offset is passed, then the first 16-bit value is returned. If the object is empty or the offset is larger than the object's size, then no value is returned.


3.12.13. get_word_32()

Synopsis

Returns the 32-bit integer value at the 4-byte offset (starting with 0) in the data passed. Of no offset is passed, then the value of the first 32-bit position at offset 0 is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.

This function assumes MSB byte order when retrieving the value from the data.

Note that this function is identical to getWord32() except that this version has no RT_NOOP variant.

See also get_word_32_lsb().

Prototype

*int get_word_32(data $data, softint $offset = 0) (CONST)

Example
my *int $val = get_word_32($bin, 2); # returns the third 32-bit value in MSB format of the binary object

Table 3.365. Arguments and Return Values for get_word_32()

Arguments

Return Type

Description

data, softint $offset = 0)

*int

The MSB integer value of the data at the 4-byte offset given in the string or binary object. If no offset is passed, then the first 32-bit value is returned. If the object is empty or the offset is larger than the object's size, then no value is returned.


3.12.14. get_word_32_lsb()

Synopsis

Returns the 32-bit integer value at the 4-byte offset (starting with 0) in the data passed. Of no offset is passed, then the value of the first 32-bit position at offset 0 is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.

This function assumes LSB byte order when retrieving the value from the data.

See also get_word_32().

Prototype

*int get_word_32_lsb(data $data, softint $offset = 0) (CONST)

Example
my *int $val = get_word_32_lsb($bin, 2); # returns the third 32-bit value in LSB format of the binary object

Table 3.366. Arguments and Return Values for get_word_32_lsb()

Arguments

Return Type

Description

data $data, softint $offset = 0)

*int

The LSB integer value of the data at the 4-byte offset given in the string or binary object. If no offset is passed, then the first 32-bit value is returned. If the object is empty or the offset is larger than the object's size, then no value is returned.


3.12.15. get_word_64()

Synopsis

Returns the 64-bit integer value at the 8-byte offset (starting with 0) in the data passed. Of no offset is passed, then the value of the first 64-bit position at offset 0 is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.

This function assumes MSB byte order when retrieving the value from the data.

See also get_word_64_lsb().

Prototype

*int get_word_64(data $data, softint $offset = 0) (CONST)

Example
my *int $val = get_word_64($bin, 2); # returns the third 64-bit value in MSB format of the binary object

Table 3.367. Arguments and Return Values for get_word_64()

Arguments

Return Type

Description

data $data, softint $offset = 0)

*int

The MSB integer value of the data at the 8-byte offset given in the string or binary object. If no offset is passed, then the first 64-bit value is returned. If the object is empty or the offset is larger than the object's size, then no value is returned.


3.12.16. get_word_64_lsb()

Synopsis

Returns the 64-bit integer value at the 8-byte offset (starting with 0) in the data passed. Of no offset is passed, then the value of the first 64-bit position at offset 0 is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.

This function assumes LSB byte order when retrieving the value from the data.

See also get_word_64().

Prototype

*int get_word_64_lsb(data $data, softint $offset = 0) (CONST)

Example
my *int $val = get_word_64_lsb($bin, 2); # returns the third 64-bit value in LSB format of the binary object

Table 3.368. Arguments and Return Values for get_word_64_lsb()

Arguments

Return Type

Description

data $data, softint $offset = 0)

*int

The LSB integer value of the data at the 8-byte offset given in the string or binary object. If no offset is passed, then the first 64-bit value is returned. If the object is empty or the offset is larger than the object's size, then no value is returned.


3.12.17. get_qore_library_info()

Synopsis

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.

Prototype

hash get_qore_library_info() (CONST)

Example
$info = get_qore_library_info();

Table 3.369. 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.370. Library Info Hash

Key

Description

PlatformOS

The operating system used to build the Qore library.

PlatformCPU

The CPU used as a target for the Qore library build.

VersionString

The full version string for this version of the Qore library.

VersionMajor

An integer giving the Qore library's major version number.

VersionMinor

An integer giving the Qore library's minor version number.

VersionSub

An integer giving the Qore library's release version number.

Build

An integer giving the Qore library's subversion revision number.

BuildHost

A string giving information about the host used to compile the Qore library.

Compiler

The compiler used to build the Qore library.

ModuleDir

The module directory assumed by default in the Qore library.

CFLAGS

The compiler flags used to compile the Qore library.

LDFLAGS

The linker flags used to link the Qore library.


3.12.18. get_qore_option_list()

Synopsis

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.

Prototype

list get_qore_option_list() (CONST)

Example
$list = get_qore_option_list();

Table 3.371. 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.372. Library Option Hash

Key

Description

option

The string description of the option

constant

A string giving the name of the constant that has the boolean value for this option.

type

The type of option.

value

The boolean value of the option.


This function does not throw any exceptions.

3.12.19. getByte()

Synopsis

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.

Prototype

*int getByte(data $data, softint $offset = 0) (CONST)

nothing getByte() (RT_NOOP)

Example
my *int $byte = getByte($bin, 2); # returns the third byte of the binary object

Table 3.373. Arguments and Return Values for getByte()

Arguments

Return Type

Description

data $data, softint $offset = 0)

*int

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.


3.12.20. getClassName()

Synopsis

Returns the class name of an object.

Prototype

string getClassName(object) (CONST)

nothing getClassName() (RT_NOOP)

Example
$name = getClassName($obj);

Table 3.374. 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.

3.12.21. getDBIDriverCapabilities()

Synopsis

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.

Prototype

*int getDBIDriverCapabilities(string)

nothing getDBIDriverCapabilities() (RT_NOOP)

Example
$caps = getDBIDriverCapabilities("oracle");

Table 3.375. Arguments and Return Values for getDBIDriverCapabilities()

Argument Type

Return Type

Description

string

*int

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.

3.12.22. getDBIDriverCapabilityList()

Synopsis

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.

Prototype

*list getDBIDriverCapabilityList(string)

nothing getDBIDriverCapabilityList() (RT_NOOP)

Example
$list = getDBIDriverCapabilityList("mysql");

Table 3.376. 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.

3.12.23. getDBIDriverList()

Synopsis

Returns a list of strings of DBI drivers currently loaded.

Prototype

*list getDBIDriverList()

Example
my *list $list = getDBIDriverList();

Table 3.377. Arguments and Return Values for getDBIDriverList()

Argument Type

Return Type

Description

n/a

*list

Returns a list of strings of DBI drivers currently loaded or NOTHING if no drivers are loaded.


This function does not throw any exceptions.

3.12.24. getFeatureList()

Synopsis

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

Prototype

list getFeatureList() (CONST)

Example
$list = getFeatureList();

Table 3.378. 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.

3.12.25. getMethodList()

Synopsis

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

Prototype

list getMethodList(object) (CONST)

nothing getMethodList() (RT_NOOP)

Example
$list = getMethodList($obj);

Table 3.379. 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 normally throw any exceptions, however an OBJECT-ALREADY-DELETED exception could be raised if there is a race condition and a stale pointer to an object is accessed with this function.

3.12.26. getModuleHash()

Synopsis

Returns a hash of hashes describing the currently-loaded Qore modules; the top-level hash keys are the module names.

This function was added in Qore 0.8.1

Prototype

hash getModuleHash() (CONST)

Example
my hash $h = getModuleHash();

Table 3.380. Arguments and Return Values for getModuleHash()

Argument Type

Return Type

Description

n/a

hash

Top-level keys are module/feature names, values are hashes describing the modules.


This function does not throw any exceptions.

3.12.27. getModuleList()

Synopsis

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

Prototype

list getModuleList() (CONST)

Example
$list = getModuleList();

Table 3.381. 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.

3.12.28. get_default_encoding()

Synopsis

Returns the name of the default character encoding for the currently-running Qore process.

Prototype

string get_default_encoding() (CONST)

Example
$encoding = get_default_encoding();

Table 3.382. 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.

3.12.29. getgrgid()

Synopsis

Returns a group information hash representing the group information for the group ID passed; or, if the group ID does not exist NOTHING is returned.

For a similar function that throws an exception if the group ID is invalid, see getgrgid2().

Prototype

*hash getgrgid(softint $gid) (CONST)

Example
my *hash $hash = getgrgid(0); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.383. Arguments and Return Values for getgrgid()

Argument Type

Return Type

Description

int $gid

*hash

Returns a hash representing the group information for the group ID passed. If the gid does not exist, NOTHING is returned. See the Group Information Hash for information about the return value.


Table 3.384. Exceptions Thrown by getgrgid()

err

desc

MISSING-FEATURE-ERROR

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


Table 3.385. Group Information Hash

Key

Type

Description

gr_name

string

The name of the group.

gr_passwd

string

The encrypted password for the group.

gr_gid

int

The group id.

gr_mem

list

List of strings giving the usernames of members of the group.


3.12.30. getgrgid2()

Synopsis

Returns a group information hash representing the group information for the group ID passed. If the group ID does not exist, an exception is raised.

For a similar function that does not throw an exception if the group ID is invalid, see getgrgid().

Prototype

hash getgrgid2(softint $gid) (CONST)

Example
my hash $hash = getgrgid2(0); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.386. Arguments and Return Values for getgrgid2()

Argument Type

Return Type

Description

int $gid

hash

Returns a hash representing the group information for the group ID passed. If the gid does not exist, an exception is thrown. See the Group Information Hash for information about the return value.


Table 3.387. Exceptions Thrown by getgrgid2()

err

desc

GETGRGID2-ERROR

The group information could not be retrieved (group does not exist or other error in call)

MISSING-FEATURE-ERROR

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


3.12.31. getgrnam()

Synopsis

Returns a group information hash representing the group information for the group name passed; or, if the group name does not exist NOTHING is returned.

For a similar function that throws an exception if the group ID is invalid, see getgrnam2().

Prototype

*hash getgrnam(string $group_name) (CONST)

Example
my *hash $hash = getgrnam("root"); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.388. Arguments and Return Values for getgrnam()

Argument Type

Return Type

Description

int $group_name

*hash

Returns a hash representing the group information for the group name passed. If the group name does not exist, NOTHING is returned. See the Group Information Hash for information about the return value.


Table 3.389. Exceptions Thrown by getgrnam()

err

desc

MISSING-FEATURE-ERROR

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


3.12.32. getgrnam2()

Synopsis

Returns a group information hash representing the group information for the group name passed. If the group name does not exist, an exception is rasied.

For a similar function that does not throw an exception if the group ID is invalid, see getgrnam().

Prototype

hash getgrnam2(string $group_name) (CONST)

Example
my hash $hash = getgrnam2("root"); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.390. Arguments and Return Values for getgrnam2()

Argument Type

Return Type

Description

string $group_name

hash

Returns a hash representing the group information for the group name passed. If the group name does not exist, an exception is thrown. See the Group Information Hash for information about the return value.


Table 3.391. Exceptions Thrown by getgrnam2()

err

desc

GETGRNAM2-ERROR

The group information could not be retrieved (group does not exist or other error in call)

MISSING-FEATURE-ERROR

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


3.12.33. getpwnam()

Synopsis

Returns a password information hash representing the user information for the user name passed; or, if the user name does not exist NOTHING is returned.

For a similar function that throws an exception if the user ID is invalid, see getpwnam2().

Prototype

*hash getpwnam(string $user_name) (CONST)

Example
my *hash $hash = getpwnam("root"); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.392. Arguments and Return Values for getpwnam()

Argument Type

Return Type

Description

int $user_name

*hash

Returns a hash representing the user information for the user name passed. If the user name does not exist, NOTHING is returned. See the Password Information Hash for information about the return value.


Table 3.393. Exceptions Thrown by getpwnam()

err

desc

MISSING-FEATURE-ERROR

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


Table 3.394. Password Information Hash

Key

Type

Description

pw_name

string

The username of the user.

pw_passwd

string

The encrypted password for the user.

pw_gecos

string

The real name or description of the user.

pw_dir

string

The user's home directory.

pw_shell

string

The user's login shell.

pw_uid

int

The user's userid.

pw_gid

int

The group id of the user's primary group.


3.12.34. getpwnam2()

Synopsis

Returns a password information hash representing the user information for the user name passed. If the user name does not exist, an exception is rasied.

For a similar function that does not throw an exception if the user ID is invalid, see getpwnam().

Prototype

hash getpwnam2(string $user_name) (CONST)

Example
my hash $hash = getpwnam2("root"); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.395. Arguments and Return Values for getpwnam2()

Argument Type

Return Type

Description

string $user_name

hash

Returns a hash representing the user information for the user name passed. If the user name does not exist, an exception is thrown. See the Password Information Hash for information about the return value.


Table 3.396. Exceptions Thrown by getpwnam2()

err

desc

GETPWNAM2-ERROR

The user information could not be retrieved (user does not exist or other error in call)

MISSING-FEATURE-ERROR

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


3.12.35. getpwuid()

Synopsis

Returns a password information hash representing the user information for the user ID passed; or, if the user ID does not exist NOTHING is returned.

For a similar function that throws an exception if the user ID is invalid, see getpwuid2().

Prototype

*hash getpwuid(softint $uid) (CONST)

Example
my *hash $hash = getpwuid(0); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.397. Arguments and Return Values for getpwuid()

Argument Type

Return Type

Description

int $uid

*hash

Returns a hash representing the user information for the user ID passed. If the uid does not exist, NOTHING is returned. See the Password Information Hash for information about the return value.


Table 3.398. Exceptions Thrown by getpwuid()

err

desc

MISSING-FEATURE-ERROR

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


3.12.36. getpwuid2()

Synopsis

Returns a password information hash representing the user information for the user ID passed. If the user ID does not exist, an exception is raised.

For a similar function that does not throw an exception if the user ID is invalid, see getpwuid().

Prototype

hash getpwuid2(softint $uid) (CONST)

Example
my hash $hash = getpwuid2(0); # returns the login information for root
Platform Availability

HAVE_UNIX_USERMGT

Restrictions

Not available with PO_NO_EXTERNAL_INFO

Table 3.399. Arguments and Return Values for getpwuid2()

Argument Type

Return Type

Description

int $uid

hash

Returns a hash representing the user information for the user ID passed. If the uid does not exist, an exception is thrown. See the Password Information Hash for information about the return value.


Table 3.400. Exceptions Thrown by getpwuid2()

err

desc

GETPWUID2-ERROR

The user information could not be retrieved (user does not exist or other error in call)

MISSING-FEATURE-ERROR

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


3.12.37. get_script_path()

Synopsis

Returns the path (directory and filename) of the current script. Returns NOTHING if unknown (i.e. no parent script, script read from stdin, etc).

Prototype

*string get_script_path() (CONST)

Example
my *string $path = get_script_path();

Table 3.401. Arguments and Return Values for get_script_path()

Argument Type

Return Type

Description

n/a

*string

Returns the path name of the current script, or NOTHING if unknown.


This function does not throw any exceptions.

3.12.38. get_script_dir()

Synopsis

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).

Prototype

*string get_script_dir() (CONST)

Example
my *string $dir = get_script_dir();

Table 3.402. Arguments and Return Values for get_script_dir()

Argument Type

Return Type

Description

n/a

*string

Returns the name of the directory for the current script, or NOTHING if unknown.


This function does not throw any exceptions.

3.12.39. get_script_name()

Synopsis

Returns the filename of the current script if known; returns NOTHING if not (i.e. no parent script, script read from stdin, etc).

Prototype

*string get_script_name() (CONST)

Example
my *string $name = get_script_name();

Table 3.403. Arguments and Return Values for get_script_name()

Argument Type

Return Type

Description

n/a

*string

Returns the filename of the current script, or NOTHING if unknown.


This function does not throw any exceptions.

3.12.40. getWord32()

Synopsis

Returns the 32-bit integer value at the 4-byte offset (starting with 0) in the data passed. Of no offset is passed, then the value of the first 32-bit position at offset 0 is returned. Note that the [] operator provides a more efficient way to retrieve a byte from a binary object.

This function assumes MSB byte order when retrieving the value from the data.

Note that this function is identical to get_word_32() except that this version has a RT_NOOP variant.

See also get_word_32_lsb().

Prototype

*int getWord32(data $data, softint $offset = 0) (CONST)

nothing getWord32() (RT_NOOP)

Example
my *int $val = getWord32($bin, 2); # returns the third 32-bit value in MSB format of the binary object

Table 3.404. Arguments and Return Values for getWord32()

Arguments

Return Type

Description

data $data, softint $offset = 0)

*int

The MSB integer value of the data at the 4-byte offset given in the string or binary object. If no offset is passed, then the first 32-bit value is returned. If the object is empty or the offset is larger than the object's size, then no value is returned.


3.12.41. has_key()

Synopsis

Returns True if the given key exists in the hash or object (does not necessarily have to have a value assigned); exceptions are only raised if string encoding errors are encountered or in case of object access errors.

Prototype

bool has_key(hash $hash, string $key) (RET_VALUE_ONLY)

bool has_key(object $obj, string $key) (RET_VALUE_ONLY)

Example
my bool $b = has_key($hash, "key");

Table 3.405. Arguments and Return Values for has_key()

Argument Type

Return Type

Description

hash $hash, string $key

bool

Returns True if the given key exists in the hash (does not necessarily have to have a value assigned), False if not.

object $obj, string $key

bool

Returns True if the given key exists in the object (does not necessarily have to have a value assigned), False if not.


Exceptions are only raised if string encoding errors are encountered or in case of object access errors.

3.12.42. hash_values()

Synopsis

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

Prototype

list hash_values(hash) (CONST)

nothing hash_values() (RT_NOOP)

Example
my list $l = hash_values($hash);

Table 3.406. 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.


This function does not throw any exceptions.

3.12.43. hextoint()

Synopsis

Returns an integer for a hexadecimal string value.

Prototype

int hextoint(string)

Example
$int = hextoint("ab3d4e0f12");

Table 3.407. Arguments and Return Values for hextoint()

Argument Type

Return Type

Description

string

int

Returns an integer for a hexadecimal string value.


This function does not throw any exceptions.

3.12.44. html_decode()

Synopsis

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

Prototype

string html_decode(string) (CONST)

nothing html_decode() (RT_NOOP)

Example
html_decode("&lt;hello&gt;"); # returns "<hello>"

Table 3.408. Arguments and Return Values for html_decode()

Argument Type

Return Type

Description

string

string

Returns a string with any HTML escape codes (ie &amp; -> &, etc) translated to the original characters.


This function does not throw any exceptions.

3.12.45. html_encode()

Synopsis

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

Prototype

string html_encode(string) (CONST)

nothing html_encode() (RT_NOOP)

Example
$str = html_encode("<hello>"); # returns "&lt;hello&gt;"

Table 3.409. 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 & -> &amp; etc) translated to the escape codes.


This function does not throw any exceptions.

3.12.46. inlist()

Synopsis

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().

Prototype

bool inlist(any $value, list $list)

bool inlist(any $value, any $other_value)

bool inlist() (RT_NOOP)

Example
my $bool = inlist(123, (True, "123", False); # this will return True

Table 3.410. Arguments and Return Values for inlist()

Argument Type

Return Type

Description

any $value, list $list

bool

Returns True if value is a member of list; types are converted if necessary.

any $value, nothing

bool

Always returns False, even if the first argument is NOTHING.

any $value, any $other_value

bool

Returns the value of the comparison of the first argument with the second argument; types are converted if necessary.


This function does not throw any exceptions.

3.12.47. inlist_hard()

Synopsis

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().

Prototype

bool inlist_hard(any $value, list $list)

bool inlist_hard(any $value, any $other_value)

Example
my $bool = inlist_hard(123, (True, "123", False); # this will return False

Table 3.411. Arguments and Return Values for inlist_hard()

Argument Type

Return Type

Description

any $value, list $list

bool

Returns True if value is a member of list; no type conversions are performed (the comparison fails if types are not equal).

any $value, nothing

bool

Always returns False.

any $value, any $other_value

bool

Returns the value of the comparison of the first argument with the second argument; no type conversions are performed (the comparison fails if the types are not equal).


This function does not throw any exceptions.

3.12.48. load_module()

Synopsis

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.

Prototype

nothing load_module(string $path_or_name)

nothing load_module() (RT_NOOP)

Example
load_module("pgsql");

Table 3.412. Arguments and Return Values for load_module()

Argument Type

Return Type

Description

string $path_or_name

nothing

Loads the module with the given name if possible, otherwise throws an exception. This function returns no value.


Table 3.413. Exceptions Thrown by load_module()

err

desc

LOAD-MODULE-ERROR

An error occurred loading the module (module not found, libraries not resolved, wrong module API, etc).


3.12.49. makeBase64String()

Synopsis

Returns a base64-encoded representation of a binary object or a string (see also makeHexString()).

Prototype

string makeBase64String(data) (CONST)

nothing makeBase64String() (RT_NOOP)

Example
$str = makeBase64String($bin);

Table 3.414. Arguments and Return Values for makeBase64String()

Argument Type

Return Type

Description

data

string

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


This function does not throw any exceptions.

3.12.50. makeHexString()

Synopsis

Returns a hex-encoded representation of a binary object or a string (see also makeBase64String()).

Prototype

string makeHexString(data) (CONST)

nothing makeHexString() (RT_NOOP)

Example
$str = makeHexString($bin);

Table 3.415. Arguments and Return Values for makeHexString()

Argument Type

Return Type

Description

data

string

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


This function does not throw any exceptions.

3.12.51. max()

Synopsis

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.

Prototype

any max(...) (CONST)

any max(list $list) (CONST)

any max(list $list, string $func_name)

any max(list $list, code $code)

Example
$max = max($complex_list, \callback_function());
$max = max(1, 2, 3, 4);

Table 3.416. Arguments and Return Values for max()

Argument Type

Return Type

Description

list $list, [code $code or string $fname]

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).

3.12.52. min()

Synopsis

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.

Prototype

any min(...) (CONST)

any min(list $list) (CONST)

any min(list $list, string $func_name)

any min(list $list, code $code)

Example
$min = min($complex_list, \callback_function());
$min = min(1, 10, 2, 3);

Table 3.417. Arguments and Return Values for min()

Argument Type

Return Type

Description

list $list, [code $code or string $func_name]

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 callback 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).

3.12.53. parse()

Synopsis

Adds the text passed to the current program's code.

Prototype

nothing parse(string $code, string $label)

nothing parse() (RT_NOOP)

Example
parse($code, "label");

Table 3.418. Arguments and Return Values for parse()

Argument Type

Return Type

Description

string $code, string $label

n/a

Parses the first string passed and adds the code to the current program with the second string as a label identifying the code or the code's source.


Table 3.419. Exceptions Thrown by parse()

err

desc

PARSE-ERROR

An error occurred parsing the text.


3.12.54. parse_url()

Synopsis

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. If the URL cannot be parsed, an exception is thrown..

For a similar function that returns NOTHING instead of throwing an exception if the URL string cannot be parsed, see parseURL().

Prototype

hash parse_url(string $url)

Example
my hash $hash = parse_url($url_string);

Table 3.420. Arguments and Return Values for parseURL()

Argument Type

Return Type

Description

string $url

hash

Parses a URL string and returns a hash of the components. URLs have the format: protocol://username:password@host:port/path, where only host is mandatory. If the URL cannot be parsed an exception is thrown.


Table 3.421. Exceptions Thrown by parse_url()

err

desc

PARSE-URL-ERROR

The URL string given could not be parsed.


3.12.55. parseBase64String()

Synopsis

Parses a base64 encoded string and returns the binary object (see also parseHexString()).

Prototype

binary parseBase64String(string)

nothing parseBase64String() (RT_NOOP)

Example
$bin = parseBase64String($base64_string);

Table 3.422. Arguments and Return Values for parseBase64String()

Argument Type

Return Type

Description

string

binary

Parses a base64 encoded string and returns the binary object.


Table 3.423. Exceptions Thrown by parseBase64String()

err

desc

BASE64-PARSE-ERROR

A syntax error occurred parsing the base64 string (invalid character, etc).


3.12.56. parseDatasource()

Synopsis

Returns a hash of the components of a datasource string.

Prototype

hash parseDatasource(string)

nothing parseDatasource() (RT_NOOP)

Example
$hash = parseDatasource($ds_string);

Table 3.424. 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: driver:user/pass@db(charset)%host:port{option=val,...}, where driver, charset, host, port, and options are optional. See parseDatasource() hash for a description of the output hash of this function.


Table 3.425. Exceptions Thrown by parseDatasource()

err

desc

DATASOURCE-PARSE-ERROR

A syntax error occurred parsing the datasource string (missing field, unexpected character, etc).


Table 3.426. parseDatasource() hash

Key

Description

type

the name of the driver, if present

user

the username given in the string

pass

the password for the connection

db

the database name for the connection

charset

The name of the DB-specific character encoding to use for the connection, if present in the string

host

the hostname for the connection, if present in the string

port

the port number to use for the connection, if present in the string

options

A hash of options given in the string, if present. Currently-supported options are min and max, which are respected by the DatasourcePool::constructor(hash) variant for setting the minimum and maximum connections in the pool, respectively.


3.12.57. parseHexString()

Synopsis

Parses a hex-encoded string and returns the binary object (see also parseBase64String()).

Prototype

binary parseHexString(string)

nothing parseHexString() (RT_NOOP)

Example
$bin = parseHexString($hex_string);

Table 3.427. Arguments and Return Values for parseHexString()

Argument Type

Return Type

Description

string

binary

Parses a hex-encoded string and returns the binary object.


Table 3.428. Exceptions Thrown by parseHexString()

err

desc

PARSE-HEX-ERROR

A syntax error occurred parsing the hex string (odd number of digits, invalid character, etc).


3.12.58. parseURL()

Synopsis

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. If the URL cannot be parsed, no value is returned.

For a similar function that throws an exception instead of returning NOTHING if the URL string cannot be parsed, see parse_url().

Prototype

*hash parseURL(string $url)

nothing parseURL() (RT_NOOP)

Example
my *hash $hash = parseURL($url_string);

Table 3.429. Arguments and Return Values for parseURL()

Argument Type

Return Type

Description

string $url

*hash

Parses a URL string and returns a hash of the components. URLs have the format: protocol://username:password@host:port/path, where only host is mandatory. If the URL cannot be parsed, no value is returned.


This function does not throw any exceptions.

3.12.59. rand()

Synopsis

Returns a random integer number (uses the C library function random() to generate the number).

Prototype

int rand()

Example
$num = rand();

Table 3.430. Arguments and Return Values for rand()

Argument Type

Return Type

Description

n/a

int

A random integer number is returned. See srand() for a function to seed the random number generator.


This function does not throw any exceptions.

3.12.60. remove_signal_handler()

Synopsis

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.

Prototype

nothing remove_signal_handler(softint)

Example
remove_signal_handler(SIGINT);
Restrictions

Not available with PO_NO_PROCESS_CONTROL

Table 3.431. Arguments and Return Values for remove_signal_handler()

Argument Type

Return Type

Description

softint

n/a

The signal number to process.


This function does not throw any exceptions.

3.12.61. reverse()

Synopsis

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.

Prototype

string reverse(string) (CONST)

list reverse(list) (CONST)

nothing reverse() (RT_NOOP)

Example
$str = reverse("ABCDEF"); # returns "FEDCBA"

Table 3.432. 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.

3.12.62. set_signal_handler()

Synopsis

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.

Prototype

nothing set_signal_handler(softint $signal, code $handler)

Example
set_signal_handler(SIGINT, \signal_handler());
Restrictions

Not available with PO_NO_PROCESS_CONTROL

Table 3.433. Arguments and Return Values for set_signal_handler()

Argument Type

Return Type

Description

softint $signal, code $handler

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.

3.12.63. sort()

Synopsis

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.

Prototype

list sort(list $list) (CONST)

list sort(list $list, code $code)

list sort(list $list, string $func_name)

nothing sort() (RT_NOOP)

Example
$list = sort($complex_list, \callback());

Table 3.434. Arguments and Return Values for sort()

Argument Type

Return Type

Description

list $list, [code $code or string $func_name]

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.

3.12.64. sortDescending()

Synopsis

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.

Prototype

list sortDescending(list $list) (CONST)

list sortDescending(list $list, code $code)

list sortDescending(list $list, string $func_name)

nothing sortDescending() (RT_NOOP)

Example
$list = sortDescending($complex_list, \callback());

Table 3.435. Arguments and Return Values for sortDescending()

Argument Type

Return Type

Description

list $list, [code $code or string $func_name]

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.

3.12.65. sortDescendingStable()

Synopsis

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.

Prototype

list sortDescendingStable(list $list) (CONST)

list sortDescendingStable(list $list, code $code)

list sortDescendingStable(list $list, string $func_name)

nothing sortDescendingStable() (RT_NOOP)

Example
$list = sortDescendingStable($complex_list, \callback());

Table 3.436. Arguments and Return Values for sortDescendingStable()

Argument Type

Return Type

Description

list $list, [code $code or string $func_name]

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.

3.12.66. sortStable()

Synopsis

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.

Prototype

list sortStable(list $list) (CONST)

list sortStable(list $list, code $code)

list sortStable(list $list, string $func_name)

nothing sortStable() (RT_NOOP)

Example
$list = sortStable($complex_list, \callback());

Table 3.437. Arguments and Return Values for sortStable()

Argument Type

Return Type

Description

list $list, [code $code or string $func_name]

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.

3.12.67. srand()

Synopsis

Seeds the random number generator with the integer passed (uses the C library function srandom()).

This function is tagged with PO_NO_PROCESS_CONTROL because it affects the process as a whole.

Prototype

nothing srand(softint)

nothing srand() (RT_NOOP)

Example
srand(now()); # seeds with current time
Restrictions

Not available with PO_NO_PROCESS_CONTROL

Table 3.438. Arguments and Return Values for srand()

Argument Type

Return Type

Description

softint

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.

3.12.68. strtoint()

Synopsis

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

Prototype

int strtoint(softstring $string, int $base = 10) (CONST)

nothing strtoint() (RT_NOOP)

Example
$int = strtoint("41", 8);

Table 3.439. Arguments and Return Values for strtoint()

Argument Type

Return Type

Description

softstring $string, int $base = 10

int

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.