chr
Description
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);
🐘
Links
String
- addcslashes
- addslashes
- bin2hex
- chop
- chunk_split
- convert_uudecode
- convert_uuencode
- count_chars
- crc32
- crypt
- echo
- explode
- fprintf
- get_html_translation_table
- hebrev
- hebrevc
- hex2bin
- html_entity_decode
- htmlentities
- htmlspecialchars
- htmlspecialchars_decode
- implode
- join
- lcfirst
- levenshtein
- localeconv
- ltrim
- md5
- md5_file
- metaphone
- nl_langinfo
- nl2br
- number_format
- ord
- parse_str
- printf
- quoted_printable_decode
- quoted_printable_encode
- quotemeta
- rtrim
- setlocale
- sha1
- sha1_file
- similar_text
- soundex
- sprintf
- sscanf
- str_contains
- str_decrement
- str_ends_with
- str_getcsv
- str_increment
- str_ireplace
- str_pad
- str_repeat
- str_replace
- str_rot13
- str_shuffle
- str_split
- str_starts_with
- str_word_count
- strcasecmp
- strchr
- strcmp
- strcoll
- strcspn
- strip_tags
- stripcslashes
- stripos
- stripslashes
- stristr
- strlen
- strnatcasecmp
- strnatcmp
- strncasecmp
- strncmp
- strpbrk
- strpos
- strrchr
- strrev
- strripos
- strrpos
- strspn
- strstr
- strtok
- strtolower
- strtoupper
- strtr
- substr
- substr_compare
- substr_count
- substr_replace
- trim
- ucfirst
- ucwords
- vfprintf
- vprintf
- vsprintf
- wordwrap