The chr() function is a built-in function in PHP and is used to convert a ASCII value to a character. It accepts an ASCII value as a parameter and returns a string representing a character from the specified ASCII value. The ASCII value can be specified in decimal, octal, or hex values.
$n1 = 35; // Dec
$n2 = 043; // Oct
$n3 = 0x23; // Hx – add 0x
echo “The equivalent character for ASCII 35 in decimal is “;
echo chr($n1), “\n”;// Decimal value
echo “The equivalent character for ASCII 043 in octal is “;
echo chr($n2), “\n”; // Octal value
echo “The equivalent character for ASCII 0x23 in hex is “;
echo chr($n3); // Hex value

Leave A Comment?