Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Generate a single-byte string from a number
<?php chr(int $codepoint): string
<?php         $mask = '';



        if ($ones = floor($prefix / 8)) {

            $mask = str_repeat(chr(255), (int) $ones);

        }



        if ($remainder = $prefix % 8) {
<?php         }



        if ($remainder = $prefix % 8) {

            $mask .= chr(0xff ^ (0xff >> $remainder));

        }



        $mask = str_pad($mask, $size, chr(0));
<?php             $mask .= chr(0xff ^ (0xff >> $remainder));

        }



        $mask = str_pad($mask, $size, chr(0));



        return $this->ipMapTo6($mask, $size);

    }
<?php         $net = '';



        for ($i = 1; $i < 17; ++$i) {

            $net .= chr($ip[$i] & $mask[$i]);

        }



        return array($net, $netmask);
<?php     private function ipMapTo6($binary, $size)

    {

        if ($size === 4) {

            $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);

            $binary = $prefix . $binary;

        }
<?php         if (!extension_loaded('mbstring')) {

            $this->markTestSkipped('Test requires the mbstring extension');

        }

        $backslash = chr(92);

        $data = '"' . $backslash . $backslash . $backslash . 'u0119"';

        $expected = '"' . $backslash . $backslash . 'ę"';