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
IntlChar isgraph() function in PHP
The IntlChar::isgraph() function checks whether a given character is a graphic character or not. Graphic characters are visible characters that have a visual representation, excluding whitespace and control characters.
Syntax
bool IntlChar::isgraph(mixed $codepoint)
Parameters
codepoint − An integer codepoint value (e.g., 0x41 for 'A'), or a character encoded as a UTF-8 string (e.g., "A").
Return Value
The IntlChar::isgraph() function returns TRUE if the codepoint is a graphic character, FALSE otherwise. Returns NULL on failure.
Example
The following example demonstrates checking various characters ?
<?php
var_dump(IntlChar::isgraph("A")); // Letter
echo "
";
var_dump(IntlChar::isgraph("9")); // Digit
echo "
";
var_dump(IntlChar::isgraph("@")); // Symbol
echo "
";
var_dump(IntlChar::isgraph(" ")); // Space (not graphic)
echo "
";
var_dump(IntlChar::isgraph("
")); // Newline (not graphic)
echo "
";
var_dump(IntlChar::isgraph("\t")); // Tab (not graphic)
?>
Output
The output of the above code is ?
bool(true) bool(true) bool(true) bool(false) bool(false) bool(false)
Key Points
Graphic characters include letters, digits, punctuation, and symbols
Whitespace characters (spaces, tabs, newlines) are not considered graphic
Control characters are not considered graphic
The function accepts both string characters and Unicode codepoint integers
Conclusion
IntlChar::isgraph() is useful for validating visible characters in text processing applications. It returns TRUE for any character that has a visual representation, excluding whitespace and control characters.
