Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
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 TRUEAlphabetic 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.
