IntlChar::isbase() function in PHP

The IntlChar::isbase() function checks whether a given character is a base character. A base character is any character that is a letter, digit, or other character that can serve as the base for combining characters.

Syntax

IntlChar::isbase(mixed $codepoint): ?bool

Parameters

  • codepoint − An integer codepoint value (e.g., 0x41 for 'A'), or a single UTF-8 character (e.g., "A"). Required.

Return Value

Returns TRUE if the character is a base character, FALSE otherwise, or NULL on failure (invalid input).

Example

The following example demonstrates checking various characters ?

<?php
    // Check single characters
    var_dump(IntlChar::isbase("D"));
    echo "<br>";
    
    var_dump(IntlChar::isbase("a"));
    echo "<br>";
    
    var_dump(IntlChar::isbase("5"));
    echo "<br>";
    
    // Check using Unicode codepoints
    var_dump(IntlChar::isbase(0x41)); // 'A'
    echo "<br>";
    
    // Invalid inputs (multi-character strings)
    var_dump(IntlChar::isbase("ABC"));
    echo "<br>";
    
    var_dump(IntlChar::isbase("123"));
?>
bool(true)
bool(true)
bool(true)
bool(true)
NULL
NULL

Key Points

  • Only accepts single characters or valid Unicode codepoints

  • Multi-character strings return NULL

  • Letters, digits, and most printable characters are base characters

  • Combining characters and control characters are typically not base characters

Conclusion

The IntlChar::isbase() function is useful for validating individual characters in Unicode text processing. Remember to pass only single characters or codepoints to avoid NULL returns.

Updated on: 2026-03-15T07:43:18+05:30

140 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements