IntlChar::charAge() function in PHP

The IntlChar::charAge() function is used to compute the age of a Unicode character, which represents the Unicode version when the character was first designated or assigned.

Syntax

array IntlChar::charAge( mixed $codepoint )

Parameters

  • codepoint − A character or integer value encoded as a UTF-8 string, or an integer representing the Unicode code point.

Return Value

The IntlChar::charAge() function returns an array containing the Unicode version number as four integers representing [major, minor, micro, update]. Returns null on failure.

Example

The following example demonstrates how to get the Unicode age of different characters −

<?php
// Check age of Latin letter 'A' (very old character)
var_dump(IntlChar::charAge("A"));
echo "<br>";

// Check age of Euro symbol (added in Unicode 2.1)
var_dump(IntlChar::charAge("?"));
echo "<br>";

// Check age of emoji (newer character)
var_dump(IntlChar::charAge("?"));
echo "<br>";

// Using integer codepoint
var_dump(IntlChar::charAge(65)); // ASCII 'A'
?>

Output

The following is the output −

array(4) { [0]=> int(1) [1]=> int(1) [2]=> int(0) [3]=> int(0) }
array(4) { [0]=> int(2) [1]=> int(1) [2]=> int(0) [3]=> int(0) }
array(4) { [0]=> int(6) [1]=> int(1) [2]=> int(0) [3]=> int(0) }
array(4) { [0]=> int(1) [1]=> int(1) [2]=> int(0) [3]=> int(0) }

Understanding the Output

The returned array represents the Unicode version as [major, minor, micro, update]. For example:

  • Letter 'A': [1, 1, 0, 0] means Unicode version 1.1.0.0

  • Euro symbol: [2, 1, 0, 0] means Unicode version 2.1.0.0

  • Emoji: [6, 1, 0, 0] means Unicode version 6.1.0.0

Conclusion

The IntlChar::charAge() function is useful for determining when a Unicode character was introduced, helping developers understand character compatibility across different Unicode versions.

Updated on: 2026-03-15T07:44:39+05:30

225 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements