Return characters from different ASCII values:
<?phpecho chr(52) . "<br>"; // Decimal valueecho chr(052) . "<br>"; // Octal valueecho chr(0x52) . "<br>"; // Hex value?>The chr() function returns characters from a 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.
chr( ascii )
parameter | describe |
---|---|
ascii | Required. ASCII value. |
Return value: | Returns the specified character. |
---|---|
PHP version: | 4+ |
Use the octal value 046 to add the ASCII character: &.
<?php$str = chr(046);echo("You $str me forever!");?>Use decimal values 43 and 61 to add the ASCII characters: + and =.
<?php $str = chr(43);$str2 = chr(61);echo("2 $str 2 $str2 4"); ?>