X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP chr() Function

PHP String Reference PHP String Reference

Example

Return characters from different ASCII values:

<?php
echo chr(52) . "<br>"; // Decimal value
echo chr(052) . "<br>"; // Octal value
echo chr(0x52) . "<br>"; // Hex value
?>

Run example »

Definition and Usage

The chr() function returns a character from the specified ASCII value.

The ASCII value can be specified in decimal, octal, or hex values. Octal values are defined by a leading 0, while hex values are defined by a leading 0x.


Syntax

chr(ascii)

Parameter Description
ascii Required. An ASCII value

Technical Details

Return Value: Returns the specified character
PHP Version: 4+


More Examples

Example 1

Using the octal value 046 to add the ASCII Character: &.

<?php
$str = chr(046);
echo("You $str me forever!");
?>

Run example »

Example 2

Using the decimal values 43 and 61 to add the ASCII Characters: + and =.

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

Run example »


PHP String Reference PHP String Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook