IntlChar::ispunct() function in PHP

The IntlChar::ispunct() function checks whether the given input character is a punctuation character or not. This function is part of PHP's Intl extension and follows Unicode standards for character classification.

Syntax

bool IntlChar::ispunct(mixed $val)

Parameters

  • val − An integer value or character encoded as a UTF-8 string. This parameter is required.

Return Value

The IntlChar::ispunct() function returns TRUE if the value is a punctuation character, FALSE otherwise. Returns NULL on failure.

Example 1

The following example demonstrates checking various characters ?

<?php
    var_dump(IntlChar::ispunct("1"));
    echo "<br>";
    var_dump(IntlChar::ispunct(","));
    echo "<br>";
    var_dump(IntlChar::ispunct("q"));
?>

The output of the above code is ?

bool(false)
bool(true)
bool(false)

Example 2

Let us see another example with different punctuation marks ?

<?php
    var_dump(IntlChar::ispunct(";"));
    echo "<br>";
    var_dump(IntlChar::ispunct(":"));
    echo "<br>";
    var_dump(IntlChar::ispunct("!"));
    echo "<br>";
    var_dump(IntlChar::ispunct("@"));
?>

The output of the above code is ?

bool(true)
bool(true)
bool(true)
bool(true)

Key Points

  • The function accepts both string characters and Unicode codepoints

  • Common punctuation marks like .,;:!? return TRUE

  • Alphabetic characters and digits return FALSE

  • Invalid input may return NULL

Conclusion

The IntlChar::ispunct() function is useful for validating and filtering punctuation characters in internationalized applications. It provides reliable Unicode-compliant character classification for text processing tasks.

Updated on: 2026-03-15T07:44:04+05:30

155 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements