Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

chr

Description

The chr of String for PHP generate a single-byte string from a number.

Syntax

chr ( int $bytevalue ) : string

Parameters

bytevalue

An integer between 0 and 255.

Values outside the valid range (0..255) will be bitwise and'ed with 255, which is equivalent to the following algorithm:

while ($bytevalue < 0)
{
    $bytevalue += 256;
}

$bytevalue %= 256;

Return

A single-character string containing the specified byte.

Examples

1

<?

$bytevalue = 97;

$return = chr($bytevalue);

echo $return;
a

2

<?

$bytevalue = -159;

$return = chr($bytevalue);

echo $return;
a

3

<?

$bytevalue = 353;

$return = chr($bytevalue);

echo $return;
a

4

<?

for ($i = 0; $i <= 255; ++$i)
{
    $ctype_print = ctype_print($i);

    if ($ctype_print)
    {
        $return = chr($i);

        echo $return;
    }
}
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

5

<?

$bytevalue = 27;

echo "escape: " . chr($bytevalue) . PHP_EOL;
echo sprintf("escape: %c", $bytevalue);
escape: 
escape: 

6

<?

echo chr(240) . chr(159) . chr(144) . chr(152);
🐘
HomeMenu