Thursday, October 16, 2025
HomeLanguagesPHP | IntlChar::chr() Function

PHP | IntlChar::chr() Function

The IntlChar::chr() function is an inbuilt function in PHP which is used to check whether the given input character is Unicode code point value or not. It returns Unicode character by code point value.
Syntax: 
 

string IntlChar::chr( $codepoint )

Parameters: This function accepts a single parameter $codepoint which is mandatory. The input parameter is a character or integer value, which is encoded as a UTF-8 string.
Return Value: In True cases, the $codepoint string contain the single character, which is specified by the Unicode code point value, otherwise return NULL.
Below programs illustrate the IntlChar::chr() function in PHP: 
Program 1: 
 

php




<?php
// PHP function to illustrate
// the use of IntlChar::chr()
    
// Input int codepoint value
var_dump(IntlChar::chr(" "));
    
// Input int codepoint value
var_dump(IntlChar::chr(101));
    
// Input char codepoint value
var_dump(IntlChar::chr("G"));
    
// Input char  codepoint value
var_dump(IntlChar::chr("Geeks"));
 
// Input Symbolic codepoint value
var_dump(IntlChar::chr("$"));
 
// Input Symbolic codepoint value
var_dump(IntlChar::chr("#"));
  
// Input Symbolic codepoint value
var_dump(IntlChar::chr("@"));
 
?>


Output: 
 

string(1) " " 
string(1) "e" 
string(1) "G" 
NULL 
string(1) "$" 
string(1) "#" 
string(1) "@" 

Program 2: 
 

php




<?php
// PHP function to illustrate the
// use of IntlChar::chr
 
// Declare an array with
// different codepoint value
$arr = array("D",
            ("E"),
             77,
            123,
            65,
            97,
      
        );
      
// For loop condition to check
// each character through function
foreach ($arr as $val) {
          
    // Check each element as code point data
    var_dump(IntlChar::chr($val));
}
?>


Output: 
 

string(1) "D" 
string(1) "E" 
string(1) "M"  
string(1) "{" 
string(1) "A" 
string(1) "a" 

Related Articles: 
 

Reference: http://php.net/manual/en/intlchar.chr.php
 

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS