Menu Close

chr() function PHP

codeamend

The chop() function Generate a single-byte string from a number.

This function complements ord().

Syntax

chr ( int $codepoint ) : string 

Parameter Values

codepoint : An integer between 0 and 255.

Technical Details

Return Value : A single-character string containing the specified byte.

PHP Version : PHP 4, PHP 5, PHP 7, PHP 8

Examples

<?php
echo chr(42) . "<br>"; // Decimal value
echo chr(042) . "<br>"; // Octal value
echo chr(0x42) . "<br>"; // Hex value
?>

Output : 
*
"
B 
<?php 
$str = chr(43);
$str2 = chr(61);
echo("2 $str 2 $str2 4"); 
?>

Output : 
2 + 2 = 4 

Share

Posted in PHP

You can also read...

Leave a Reply

Your email address will not be published.