Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
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.
