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.

Updated on: 2026-03-15T07:47:00+05:30

129 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements