Thursday, September 4, 2025
HomeLanguagesPHP | IntlChar getPropertyName() Function

PHP | IntlChar getPropertyName() Function

The IntlChar::getPropertyName() function is an inbuilt function in PHP which is used to get the Unicode name for a given property which is given in the Unicode database file PropertyAliases.txt. This function maps the property IntlChar::PROPERTY_GENERAL_CATEGORY_MASK to the synthetic names “gcm” / “General_Category_Mask” which are not in the PropertyAliases.txt. This function is the compliments of IntlChar::getPropertyEnum() function.
 

Syntax:  

string IntlChar::getPropertyName( $property, $nameChoice = 
IntlChar::LONG_PROPERTY_NAME )

Parameters: This function accepts two parameters as mentioned above and described below:  

  • $property: This parameter holds the Unicode Property constants (IntlChar::PROPERTY_* constants) 
    The list of property constants are: 
    • IntlChar::PROPERTY_ALPHABETIC
    • IntlChar::PROPERTY_BIDI_MIRRORED
    • IntlChar::PROPERTY_BIDI_CLASS
    • IntlChar::PROPERTY_DASH
    • IntlChar::PROPERTY_IDEOGRAPHIC
    • IntlChar::PROPERTY_LOWERCASE
    • IntlChar::PROPERTY_MATH
    • IntlChar::PROPERTY_UPPERCASE
    • IntlChar::PROPERTY_WHITE_SPACE etc…
  • $nameChoice This parameter holds the selector which gets the which Unicode name.

Return Values: This function returns the name on success or False if either the property or name choice is out of range.
Below programs illustrate the IntlChar::getPropertyName() function in PHP:
Program 1: 

php




<?php
// Program illustrates the IntlChar::getPropertyName() function
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED));
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED,
        IntlChar::SHORT_PROPERTY_NAME));
         
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED,
        IntlChar::LONG_PROPERTY_NAME));
         
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_MIRRORED,
        IntlChar::LONG_PROPERTY_NAME + 1));
 
?>


Output: 

string(13) "Bidi_Mirrored"
string(6) "Bidi_M"
string(13) "Bidi_Mirrored"
bool(false)

 

Program 2: 

php




<?php
// Program illustrates the IntlChar::getPropertyName() function
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC));
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC,
        IntlChar::SHORT_PROPERTY_NAME));
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC,
        IntlChar::LONG_PROPERTY_NAME));
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_IDEOGRAPHIC,
        IntlChar::LONG_PROPERTY_NAME + 1));
?>


Output: 

string(11) "Ideographic"
string(4) "Ideo"
string(11) "Ideographic"
bool(false)

 

Program 3: 

php




<?php
// Program illustrates the IntlChar::getPropertyName() function
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK));
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK,
        IntlChar::SHORT_PROPERTY_NAME));
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK,
        IntlChar::LONG_PROPERTY_NAME));
 
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_GENERAL_CATEGORY_MASK,
        IntlChar::LONG_PROPERTY_NAME + 1));
 
?>


Output: 

string(21) "General_Category_Mask"
string(3) "gcm"
string(21) "General_Category_Mask"
bool(false)

 

Reference https://www.php.net/manual/en/intlchar.getpropertyname.php

RELATED ARTICLES

Most Popular

Dominic
32263 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11857 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6696 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS