IntlChar::isIDPart() function in PHP

The IntlChar::isIDPart() function is used to check whether a given character can be part of an identifier in programming languages. This function follows Unicode standards to determine if a character is valid for use in identifiers.

Syntax

bool IntlChar::isIDPart(mixed $codepoint)

Parameters

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

Return Value

The IntlChar::isIDPart() function returns TRUE if the character can be part of an identifier, FALSE otherwise, or NULL on failure.

Example

The following example demonstrates how to check various characters ?

<?php
   var_dump(IntlChar::isIDPart("J"));
   echo "<br>";
   var_dump(IntlChar::isIDPart("j"));
   echo "<br>";
   var_dump(IntlChar::isIDPart("5"));
   echo "<br>";
   var_dump(IntlChar::isIDPart("&"));
   echo "<br>";
   var_dump(IntlChar::isIDPart("_"));
   echo "<br>";
   var_dump(IntlChar::isIDPart(" "));
?>
bool(true)
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)

Key Points

  • Letters (both uppercase and lowercase) are valid identifier parts

  • Digits can be part of identifiers but typically not at the start

  • Underscores are considered valid identifier characters

  • Special characters like & and spaces are not valid identifier parts

Conclusion

The IntlChar::isIDPart() function is useful for validating characters that can appear in programming language identifiers according to Unicode standards.

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

151 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements