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 | base64_enc(s [, no_padding]) |
| Feature | Encodes a string in Base64. |
| Parameters |
|
| Return values | A Base64-encoded string. |
| Examples | |
base64_dec
| Item | Description |
|---|---|
| Syntax | base64_dec(s) |
| Feature | Decodes a Base64-encoded string. |
| Parameters | s: the string that you want to decode. |
| Return values | A decoded raw string. |
| Examples | |
url_escape
| Item | Description |
|---|---|
| Syntax | url_escape(s) |
| Feature | Uses URL encoding to encode a string. |
| Parameters | s: the string that you want to encode. |
| Return values | A URL-encoded string. |
| Examples | Output: |
url_unescape
| Item | Description |
|---|---|
| Syntax | url_unescape(s) |
| Feature | Decodes a URL-encoded string. |
| Parameters | s: the string that you want to decode. |
| Return values | A decoded raw string. |
| Examples | Output: |
randomseed
| Item | Description |
|---|---|
| Syntax | randomseed() |
| Feature | Generates a random seed. |
| Parameters | None. |
| Return values | None. |
| Examples | |
rand
| Item | Description |
|---|---|
| Syntax | rand(n1, n2) |
| Feature | Generates a random number. Valid values: n1 ≤ returned number ≤ n2. |
| Parameters |
|
| Return values | A random number. |
| Examples | |
rand_hit
| Item | Description |
|---|---|
| Syntax | rand_hit(ratio) |
| Feature | Retrieves a value of true or false based on the specified probability. |
| Parameters | ratio: the probability. Valid values: 0 to 100. |
| Return values | true or false is returned based on the specified probability. If you set ratio to 100, true is returned. If you set ratio to 0, false is returned. |
| Examples | |
crc
| Item | Description |
|---|---|
| Syntax | crc(s) |
| Feature | Calculates a Cyclic Redundancy Check (CRC) digest. |
| Parameters | s: the string for which you want to calculate a CRC digest. |
| Return values | The CRC value of the string specified by the s parameter. |
| Examples | |
tonumber
| Item | Description |
|---|---|
| Syntax | tonumber(s [, base]) |
| Feature | Converts a string to the numeric type. |
| Parameters |
|
| Examples | |
base64_enc_safe
| Item | Description |
|---|---|
| Syntax | base64_enc_safe(str) |
| Feature | 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. |
| Parameters | str: the string that you want to encode. |
| Return values | A Base64-encoded string. |
| Examples | Response header: |
base64_dec_safe
| Item | Description |
|---|---|
| Syntax | base64_dec_safe(str) |
| Feature | 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. |
| Parameters | str: the Base64-encoded string that you want to decode. |
| Return values | A decoded raw string. |
| Examples | Response header: |