IntlChar::isJavaSpaceChar() function in PHP

The IntlChar::isJavaSpaceChar() function is used to check whether the entered value is a space character or not according to Java conventions.

Syntax

IntlChar::isJavaSpaceChar(mixed $codepoint)

Parameters

  • codepoint − A character value encoded as a UTF-8 string or an integer representing a Unicode codepoint.

Return Value

The IntlChar::isJavaSpaceChar() function returns TRUE if the value is a space character according to Java conventions, FALSE otherwise. Returns NULL on failure.

Example

The following example demonstrates different space characters and non-space characters ?

<?php
    var_dump(IntlChar::isJavaSpaceChar(""));
    echo "<br>";
    var_dump(IntlChar::isJavaSpaceChar("!"));
    echo "<br>";
    var_dump(IntlChar::isJavaSpaceChar(" "));
    echo "<br>";
    var_dump(IntlChar::isJavaSpaceChar("K"));
    echo "<br>";
    var_dump(IntlChar::isJavaSpaceChar("Kite!"));
    echo "<br>";
    var_dump(IntlChar::isJavaSpaceChar("\t"));
    echo "<br>";
    var_dump(IntlChar::isJavaSpaceChar("<br>"));
?>
NULL
bool(false)
bool(true)
bool(false)
NULL
bool(true)
bool(true)

Key Points

  • Returns NULL for empty strings or multi-character strings
  • Identifies space characters including regular space, tab (\t), and newline (
    )
  • Compatible with Java's Character.isSpaceChar() method
  • Part of PHP's Internationalization (Intl) extension

Conclusion

The IntlChar::isJavaSpaceChar() function provides Java-compatible space character detection in PHP. It's useful for text processing applications that need to maintain compatibility with Java's whitespace handling conventions.

Updated on: 2026-03-15T07:45:23+05:30

89 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements