Home »
PHP
PHP chr() function with example
PHP chr() function: Here, we are going to learn about the chr() function with example in PHP.
Submitted by IncludeHelp, on February 03, 2019
PHP chr() function
chr() function is used to get the character from a given ASCII code. ASCII value can be in decimal format, octal format by following 0 (zero), and hexadecimal format by following 0x.
Syntax:
chr(ASCII_value);
Function accepts ASCII value in number and returns corresponding character.
Examples:
Input: 65
Output: 'A'
Input: 0x41
Output: 'A'
PHP code:
<?php
echo (chr(65)."\n"); //ASCII value of 'A' in decimal
echo (chr(0101)."\n"); //ASCII value of 'A' in octal
echo (chr(0x41)."\n"); //ASCII value of 'A' in hex
?>
Output
A
A
A
TOP Interview Coding Problems/Challenges