PHP chr() Function
Definition
To convert an ASCII number to its character equivalent, use the chr()
function.
chr()
takes an ASCII value and returns the character equivalent, if there is one.
chr()
has the following format.
Syntax
PHP chr() Function has the following syntax.
string chr ( int ascii_val )
Parameter
ascii_val
is the value to convert.
Return
PHP chr() function returns character from ascii number.
Note
The ord()
function does the opposite of chr()
:
it takes a string and returns the equivalent ASCII value.
Example
Convert number to character
<?PHP
$letter = chr(100);
print "ASCII number 100 is equivalent to $letter\n";
?>
The code above generates the following result.