This topic describes the syntax, description, parameters, and return values of miscellaneous functions. This topic also provides examples of these functions.
base64_enc
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | base64_enc(s [, no_padding])
|
Description | Encodes a string in Base64. |
Parameter |
|
Return value | Returns a Base64-encoded string. |
Example |
|
base64_dec
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | base64_dec(s)
|
Description | Decodes a Base64-encoded string. |
Parameter | s: the string that you want to decode. |
Return value | Returns a decoded raw string. |
Example |
|
url_escape
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | url_escape(s)
|
Description | Uses URL encoding to encode a string. |
Parameter | s: the string to be decoded. |
Return value | Returns a URL-encoded string. |
Example |
|
url_unescape
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | url_unescape(s)
|
Description | Decodes a URL-encoded string. |
Parameter | s: the string that you want to decode. |
Return value | Returns a decoded raw string. |
Example | Output:
|
rand
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | rand(n1, n2)
|
Description | Generates and returns a random number. Value values: n1 <= returned number <= n2. The n1 parameter specifies the smallest number. The n2 parameter specifies the greatest number. |
Parameter |
|
Return value | Returns a random number. |
Example |
|
rand_hit
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | rand_hit(ratio)
|
Description | Retrieves a value of true or false based on the specified probability. |
Parameter | ratio: the probability. Valid values: 0 to 100. |
Return value | Returns true or false based on the specified probability. If you set ratio to 100, true is returned. If you set ratio to 0, false is returned.
|
Example |
|
crc
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | crc(s)
|
Description | Calculates a Cyclic Redundancy Check (CRC) value. |
Parameter | s: the string for which you want to calculate a CRC digest. |
Return value | Returns the CRC value of the string specified by the s parameter.
|
Example |
|
tonumber
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | tonumber(s [, base])
|
Description | Converts a string to the numeric type. |
Parameter |
|
Example |
|
base64_enc_safe
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | base64_enc_safe(str)
|
Description | Encodes a string in Base64. In the encoded string, plus signs (+) are replaced by minus signs (-), forward slashes (/) are replaced by underscores (_), and equal signs (=) are removed. |
Parameter | str: the string that you want to encode. |
Return value | Returns a decoded raw string. |
Example | Response header:
|
base64_dec_safe
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | base64_dec_safe(str)
|
Description | Decodes a Base64-encoded string. In the decoded string, minus signs (-) are replaced by plus signs (+) and underscores (_) are replaced by forward slashes (/). Equal signs (=) are added to the end of the string to ensure that the string is padded to a multiple of four characters. |
Parameter | str: the Base64-encoded string that you want to decode. |
Return value | Returns a decoded raw string. |
Example | Response header:
|
randomseed
The following table describes the details about this function.
Item | Description |
---|---|
Syntax | randomseed()
|
Description | Generates a random seed. |
Parameter | N/A |
Return value | N/A |
Example |
|