IntlChar isdefined() function in PHP

The IntlChar::isdefined() function checks whether a Unicode character is defined in the Unicode standard. It determines if the given character has an assigned meaning and properties.

Syntax

bool IntlChar::isdefined(mixed $codepoint)

Parameters

  • codepoint − An integer or single character encoded as a UTF-8 string representing a Unicode code point.

Return Value

Returns TRUE if the character is defined in Unicode, FALSE otherwise, or NULL on failure (invalid input).

Example

The following example demonstrates checking various characters ?

<?php
    // Check defined characters
    var_dump(IntlChar::isdefined("Z"));
    echo "<br>";
    
    // Check space character
    var_dump(IntlChar::isdefined(" "));
    echo "<br>";
    
    // Check invalid input (multiple characters)
    var_dump(IntlChar::isdefined("HJHK"));
    echo "<br>";
    
    // Check invalid input (multiple characters)
    var_dump(IntlChar::isdefined("89"));
    echo "<br>";
    
    // Check with Unicode code point
    var_dump(IntlChar::isdefined(65)); // 'A'
    echo "<br>";
    
    // Check undefined character (private use area)
    var_dump(IntlChar::isdefined(0xE000));
?>

Output

The following is the output ?

bool(true)
bool(true)
NULL
NULL
bool(true)
bool(false)

Key Points

  • The function only accepts single characters or integer code points

  • Multi-character strings return NULL

  • Both printable and non-printable defined characters return TRUE

  • Characters in private use areas typically return FALSE

Conclusion

The IntlChar::isdefined() function is useful for validating whether Unicode characters are officially defined in the Unicode standard, helping ensure proper character handling in internationalized applications.

Updated on: 2026-03-15T07:49:54+05:30

136 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements