Miscellaneous functions
This topic describes the syntax, features, parameters, and return values of miscellaneous functions. This topic also provides examples of these functions.
base64_enc | base64_dec | url_escape | url_unescape | randomseed | rand | rand_hit | crc | tonumber | base64_enc_safe | base64_dec_safe
base64_enc
Item | Description |
Syntax |
|
Description | Base64 encoding. |
Parameters |
|
Return value | The Base64-encoded string. |
Example | Request header: Response: |
base64_dec
Item | Description |
Syntax |
|
Description | Decodes a Base64-encoded string. |
Parameters | s: The string to decode. |
Return value | The decoded string. |
Example | Request header: Response: |
url_escape
Item | Description |
Syntax |
|
Description | URL encoding. |
Parameters | s: The string to encode. |
Return value | The URL-encoded string. |
Example | Outputs: |
url_unescape
Item | Description |
Syntax |
|
Description | Decodes a URL-encoded string. |
Parameters | s: The string to decode. |
Return value | Returns a URL-decoded string. |
Example | Outputs: |
randomseed
Item | Description |
Syntax |
|
Description | Specifies a seed for random number generation. |
Parameters | None. |
Return value | None. |
Example | |
rand
Item | Description |
Syntax |
|
Description | Generates a random number. The number is between n1 and n2, inclusive. |
Parameters |
|
Return value | This operation returns the generated random number. |
Example | |
rand_hit
Item | Description |
Syntax |
|
Description | Returns true or false based on a specified probability. |
Parameters | ratio: The probability of returning true. The value must be between 0 and 100. |
Return value | Returns |
Example | |
crc
Item | Description |
Syntax |
|
Description | Calculates a Cyclic Redundancy Check (CRC) digest. |
Parameters | s: The string for which to calculate the CRC digest. |
Return value | The CRC digest of the string |
Example | |
tonumber
Item | Description |
Syntax |
|
Description | Converts a string to a number. |
Parameters |
|
Example | Output: |
base64_enc_safe
Item | Description |
Syntax |
|
Description | Performs URL-safe Base64 encoding on a string. In the output, `+` is replaced with `-`, `/` is replaced with `_`, and any trailing `=` padding is removed. |
Parameters | str: The string to encode. |
Return value | Returns a string. |
Example | Response header: |
base64_dec_safe
Item | Description |
Syntax |
|
Description | Decodes a URL-safe Base64-encoded string. Before decoding, `-` is replaced with `+`, `_` is replaced with `/`, and the string is padded with `=` at the end to a multiple of 4 characters. |
Parameters | str: The URL-safe Base64-encoded content. |
Return value | Returns a string. |
Example | Response header: |