Open In App

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:  

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
// 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
// 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
// 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


Article Tags :