PHP chr() Function
Example
Return characters from different ASCII values:
"; // Decimal value echo chr(052) . ""; // Octal value echo chr(0x52) . "
"; // Hex value ?>
Run Example »
Definition and Usage
The chr() function returns a character from a specified ASCII value.
ASCII values can be specified as decimal, octal or hexadecimal values. Octal values are defined with a leading 0, and hexadecimal values are defined with a leading 0x.
Syntax
chr(
ascii
)
| Parameters | Description |
|---|---|
| ascii | Required. The ASCII value. |
Technical Details
| Return Value: | Returns the specified character. |
|---|---|
| PHP Version: | 4+ |
More examples
Example 1
Use octal value 046 to add the ASCII character: &
Run Example »
Example 2
Use decimal values 43 and 61 to add the ASCII characters: + and =.
Run Example »
PHP String Reference Manual