chr in PHP

Syntax of chr in PHP

string chr(int char)

Returns a string consisting of the single ASCII character char.

Example of chr in PHP

// Assumes the string will be used as ASCII or an ASCII-compatible encoding

$str = "The string ends in escape: ";
$str .= chr(27); /* add an escape character at the end of $str */

/* Often this is more useful */

$str = sprintf("The string ends in escape: %c", 27);

More Example of chr in PHP

echo chr(-159), chr(833), PHP_EOL;

Leave a Comment