Open In App

PHP | IntlChar getPropertyName() Function

Improve
Improve
Like Article
Like
Save
Share
Report

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



Last Updated : 13 Sep, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads