php chr function is used to return characters from the specified ASCII value. The syntax is chr(ascii), the parameter ascii is required and refers to the ASCII value. ASCII values can be specified as decimal, octal, or hexadecimal values.
#How to use php chr function?
Definition and Usage
The chr() function returns the character from the specified ASCII value.
ASCII values can be specified as decimal, octal, or hexadecimal values. Octal values are defined with leading 0, and hexadecimal values are defined with leading 0x.
Syntax
chr(ascii)
Parameters
ascii required. ASCII value.
Return value: Returns the specified character.
PHP Version: 4
Example 1
Use the octal value 046 to add the ASCII character: &.
Output:
You & me forever!
Example 2
Use decimal values 43 and 61 to add ASCII characters: and =.
Output:
2 + 2 = 4
Example 3
Returning characters from different ASCII values:
"; // 十进制 echo chr(061) . "
"; // 八进制值 echo chr(0x61) . "
"; // 十六进制值 ?>
Output:
= 1 a
The above is the detailed content of How to use php chr function?. For more information, please follow other related articles on the PHP Chinese website!