IntlChar::isIDStart() function in PHP

The IntlChar::isIDStart() function is used to check whether the entered character is permissible as the first character of an identifier or not.

Syntax

bool IntlChar::isIDStart(mixed $codepoint)

Parameters

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

Return Value

The IntlChar::isIDStart() function returns TRUE if the value is a character that can be used as the first character of an identifier, FALSE otherwise. Returns NULL on failure.

Example

The following example demonstrates checking various characters for identifier start validity −

<?php
    var_dump(IntlChar::isIDStart("Tom"));
    echo "<br>";
    var_dump(IntlChar::isIDStart("9"));
    echo "<br>";
    var_dump(IntlChar::isIDStart("A"));
    echo "<br>";
    var_dump(IntlChar::isIDStart("_"));
    echo "<br>";
    var_dump(IntlChar::isIDStart("$"));
?>
NULL
bool(false)
bool(true)
bool(true)
bool(false)

Key Points

  • Letters (A-Z, a-z) and underscores are typically valid identifier start characters

  • Numbers (0-9) cannot be the first character of an identifier

  • Multi-character strings return NULL as the function expects a single character

  • The function follows Unicode identifier rules

Conclusion

The IntlChar::isIDStart() function is useful for validating whether a character can begin an identifier according to Unicode standards. It returns TRUE for valid identifier start characters like letters and underscores, but FALSE for numbers and special symbols.

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

82 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements