PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP - String chr() Function



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 example below, 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