Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP String chr() function returns a character from the specified ASCII value. This function can take ASCII value specified in decimal, octal, or hex values.

Octal ASCII values start with 0 followed by ASCII value.

Hex ASCII values start with 0x followed by ASCII value.

Syntax

chr(ascii)

Parameters

ascii Required. Specify ASCII value specified in decimal, octal, or hex values.

Return Value

Returns a character from the specified ASCII value.

Example:

In the below example, chr() function returns a character from the specified ASCII value.

<?php
echo chr(65)."\n";
echo chr(0101)."\n";
echo chr(0x41)."\n";
?>

The output of the above code will be:

A
A
A 

❮ PHP String functions

5