chr
Generate single-byte strings from numbers
The chr()
function returns a character from the specified ASCII value.
ASCII value can be specified as a decimal value, an octal value, or a hexadecimal value. The octal value is defined as prefixed 0, while the hexadecimal value is defined as prefixed 0x.
Return characters from different ASCII values:
<?php echo chr ( 61 ) . "<br>" ; // decimal echo chr ( 061 ) . "<br>" ; // Octal value echo chr ( 0x61 ) . "<br>" ; // Hexadecimal value ?>
Try it yourself
Use the octal value 046 to add the ASCII character:&.
<?php $str = chr ( 046 ) ; echo ( "You $str me forever!" ) ; ?>
Try it yourself
Use decimal values 43 and 61 to add ASCII characters: + and =.
<?php $str = chr ( 43 ) ; $str2 = chr ( 61 ) ; echo ( "2 $str 2 $str2 4" ) ; ?>
Try it yourself
chr ( ascii )
parameter | describe |
---|---|
ascii | Required. ASCII value. |