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 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
NULLBoth printable and non-printable defined characters return
TRUECharacters 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.
